Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clc
- clear
- disp('kalkulator +, -, *, /, ^');
- x=input('podaj znak działania: ','s');
- if x~= '+ - * / ^';
- disp('podaj dzialanie jeszcze raz');
- x=input('podaj znak działania: ','s');
- end
- switch x
- case '+'
- a=input('podaj wartosc liczby a= ')
- b=input('podaj wartosc liczby b= ')
- c=a+b;
- disp(['suma=',num2str(round(c,2))])
- case '-'
- a=input('podaj wartosc liczby a= ')
- b=input('podaj wartosc liczby b= ')
- c=a-b;
- disp(['roznica=',num2str(round(c,2))])
- case '*'
- a=input('podaj wartosc liczby a= ')
- b=input('podaj wartosc liczby b= ')
- c=a*b;
- disp(['iloczyn=',num2str(round(c,2))])
- case '/'
- a=input('podaj wartosc liczby a= ')
- b=input('podaj wartosc liczby b= ')
- if b==0
- disp('nie dzielimy przez 0')
- else
- c=a/b;
- disp(['iloraz=',num2str(round(c,2))])
- end
- case '^'
- a=input('podaj wartosc liczby a= ')
- b=input('podaj wartosc liczby b= ')
- c=a^b;
- disp(['potega=',num2str(round(c,2))])
- otherwise
- disp('błąd')
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement