Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Quad_Calc_NG ()
- disp('This program uses the explicit formula to solve a quadratic equation using "a", "b" and "c" values given by the user.')
- Run_Calc = 1;
- while (Run_Calc == 1)
- A=input(['Please enter an "a" value:']);
- B=input(['Please enter a "b" value:']);
- C=input(['Please enter a "c" value:"']);
- X1=(-B+sqrt(B^2-4*A*C))/(2*A);
- X2=(-B-sqrt(B^2-4*A*C))/(2*A);
- if (! iscomplex(X1))
- disp(['X1 =' num2str(X1)])
- disp(['X2 =' num2str(X2)])
- else
- disp(["NOPE! Wont work!"]);
- endif
- Run_Calc=input('Would you like to run another calculation? 1 = yes, any other number = no ');
- endwhile
- disp('Goodbye')
Add Comment
Please, Sign In to add comment