Guest User

Untitled

a guest
Jul 19th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.62 KB | None | 0 0
  1. function Quad_Calc_NG ()
  2. disp('This program uses the explicit formula to solve a quadratic equation using "a", "b" and "c" values given by the user.')
  3. Run_Calc = 1;
  4.  
  5. while (Run_Calc == 1)
  6.     A=input(['Please enter an "a" value:']);
  7.     B=input(['Please enter a "b" value:']);
  8.     C=input(['Please enter a "c" value:"']);
  9.     X1=(-B+sqrt(B^2-4*A*C))/(2*A);
  10.     X2=(-B-sqrt(B^2-4*A*C))/(2*A);
  11.     if (! iscomplex(X1))
  12.         disp(['X1 =' num2str(X1)])
  13.         disp(['X2 =' num2str(X2)])
  14.     else
  15.         disp(["NOPE! Wont work!"]);
  16.     endif
  17.     Run_Calc=input('Would you like to run another calculation? 1 = yes, any other number = no ');
  18. endwhile
  19. disp('Goodbye')
Add Comment
Please, Sign In to add comment