EmperorPhoenix

Actually Fixed Cylinder Calc

Sep 19th, 2015
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 1.63 KB | None | 0 0
  1. Program PracticeCalc;
  2.  
  3. Uses
  4.     crt;
  5.    
  6. Var
  7.     ResponseA:string;
  8.     ResponseB:string;
  9.     SurfaceArea:Real;
  10.     Volume:Real;
  11.     Height:Real;
  12.     Radius:Real;
  13.    
  14. Begin
  15.     ResponseA:='';
  16.     ResponseB:='';
  17.     Volume:=0;
  18.     Height:=0;
  19.     Radius:=0; 
  20.    
  21.     writeln('Would you like to calculate the volume of a cylinder? (Yes/No)');
  22.     readln(ResponseA);
  23.     ResponseA:=UpCase(ResponseA);
  24.    
  25.     while((ResponseA[1]<>'Y')and(ResponseA[1]<>'N')) do
  26.         Begin
  27.             writeln('Please enter a valid response');
  28.             readln(ResponseA);
  29.             ResponseA:=UpCase(ResponseA);
  30.         End;
  31.    
  32.     If (ResponseA[1]='Y') then
  33.         Begin
  34.             writeln('Please enter a value for height.');
  35.             readln(Height);
  36.             writeln('Please enter a value for radius.');
  37.             readln(Radius);
  38.             Volume:=sqr(Radius)*(PI)*(Height);
  39.             writeln('The Volume is ', Volume:0:2);
  40.             readln();
  41.         End;
  42.        
  43.     clrscr;
  44.    
  45.     writeln('Would you like to calculate the surface area of a cylinder? (Yes/No)');
  46.     readln(ResponseB);
  47.     ResponseB:=UpCase(ResponseB);
  48.    
  49.     while((ResponseB[1]<>'Y')and(ResponseB[1]<>'N')) do
  50.         Begin
  51.             writeln('Please enter a valid response');
  52.             readln(ResponseB);
  53.             ResponseB:=UpCase(ResponseB);
  54.         End;
  55.        
  56.     If (ResponseB[1]='Y') then
  57.         Begin
  58.             clrscr;
  59.             writeln('Please enter a value for height.');
  60.             readln(Height);
  61.             writeln('Please enter a value for radius');
  62.             readln(Radius);
  63.             SurfaceArea:=((2*PI*Radius*Height)+(2*PI*sqr(Radius)));
  64.             writeln('The Surface Area is ', SurfaceArea:0:2);
  65.             readln();
  66.         End;
  67.        
  68.     clrscr;
  69.    
  70.     If (ResponseA[1]='Y') then
  71.         writeln('Volume: ', Volume:0:2);
  72.     If (ResponseB[1]='Y') then
  73.         writeln('Surface area: ', SurfaceArea:0:2);
  74.        
  75.     readln();
  76. End.
Advertisement
Add Comment
Please, Sign In to add comment