Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Program PracticeCalc;
- Uses
- crt;
- Var
- ResponseA:string;
- ResponseB:string;
- SurfaceArea:Real;
- Volume:Real;
- Height:Real;
- Radius:Real;
- Begin
- ResponseA:='';
- ResponseB:='';
- Volume:=0;
- Height:=0;
- Radius:=0;
- writeln('Would you like to calculate the volume of a cylinder? (Yes/No)');
- readln(ResponseA);
- ResponseA:=UpCase(ResponseA);
- while((ResponseA[1]<>'Y')and(ResponseA[1]<>'N')) do
- Begin
- writeln('Please enter a valid response');
- readln(ResponseA);
- ResponseA:=UpCase(ResponseA);
- End;
- If (ResponseA[1]='Y') then
- Begin
- writeln('Please enter a value for height.');
- readln(Height);
- writeln('Please enter a value for radius.');
- readln(Radius);
- Volume:=sqr(Radius)*(PI)*(Height);
- writeln('The Volume is ', Volume:0:2);
- readln();
- End;
- clrscr;
- writeln('Would you like to calculate the surface area of a cylinder? (Yes/No)');
- readln(ResponseB);
- ResponseB:=UpCase(ResponseB);
- while((ResponseB[1]<>'Y')and(ResponseB[1]<>'N')) do
- Begin
- writeln('Please enter a valid response');
- readln(ResponseB);
- ResponseB:=UpCase(ResponseB);
- End;
- If (ResponseB[1]='Y') then
- Begin
- clrscr;
- writeln('Please enter a value for height.');
- readln(Height);
- writeln('Please enter a value for radius');
- readln(Radius);
- SurfaceArea:=((2*PI*Radius*Height)+(2*PI*sqr(Radius)));
- writeln('The Surface Area is ', SurfaceArea:0:2);
- readln();
- End;
- clrscr;
- If (ResponseA[1]='Y') then
- writeln('Volume: ', Volume:0:2);
- If (ResponseB[1]='Y') then
- writeln('Surface area: ', SurfaceArea:0:2);
- readln();
- End.
Advertisement
Add Comment
Please, Sign In to add comment