mdhat13

need program to terminate on "no" value

Feb 15th, 2012
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.57 KB | None | 0 0
  1. #!C:\Strawberry\perl\bin
  2. use warnings;
  3.    
  4. until ($stop != 0) {   
  5.    
  6. $stop = 0;
  7.    
  8. print "this program will compute the circumfrence of a circle.\n";
  9. print "\n";
  10. print "Please enter in the radius of your circle.\n";
  11. $radius = <STDIN>;
  12. until ($radius ne "\n") {
  13.     print "please enter a number ";
  14.     $radius = <STDIN>;
  15. }
  16.  
  17. print "The radius of your circle is "; 
  18. print 2 * 3.141592654 * $radius;
  19. print "\n";
  20. print "do you want to calculate another?(yes/no)\n";
  21. $answer = <STDIN>;
  22. if ($answer eq "no") {
  23.     print "exiting.... \n";
  24.     $stop = 1;
  25.     exit;
  26. } else {
  27.     $stop = 0;
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment