Multiple switch cases for different operations
Show older comments
Hi all, I want to do 3 processes. At first time i want to do some arithmetic operations which i can do it using switch cases.. After calculating i want to do another operation, for that i need to use first operation value. In third operation, again i have multiple case from that i have to choose what ever i want for that i want to use my second operation values...
If anyone know, pls suggest me too..
I tried this but i dint get the answer..
clear; clc; n=input('Please enter the figure:','s'); switch n case ('triangle'); n=3; sum=(n-1).*(180); case ('square'); n=4; sum=(n-1).*(180); case('pentagon'); n=5; sum=(n-2).*(180); case ('hexagon'); n=6; sum=(n-3).*(180); result=sum; end
result=input('Please enter the figure:','s'); switch result case('add'); addition=result+100; case('mul'); multn=result.*1; end
Anyother solutios (apart from switch case) also Welcome!
Thanks in advance.
1 Comment
Accepted Answer
More Answers (0)
Categories
Find more on Power Converters in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!