Answer to Question #316161 in Algorithms for KeKo

Question #316161

Switch Statement


Write a small program that displays a menu with the following options:


   Program that will calculate either the diameter, circumference or area of a circle. Select your choice.

  1. Diameter
  2. Circumference
  3. Area 

Use the switch statement. The program is to ask for the radius of a circle. Present the menu and execute the corresponding calculation.



1
Expert's answer
2022-03-22T15:20:09-0400


Start
Declare Real Diameter
Declare Real Circumference
Declare Real Area
Declare Real radius 
Declare Real PI = 3.14159
Declare Integer choice 
Print "Enter the radius of a circle: "
Input radius 
Print "1. Diameter"
Print "2. Circumference"
Print "3. Area"
Input choice
switch(choice)
case 1:
   Set Diameter=radius * 2
   Print "Diameter: "+Diameter
case 2:
   Set Circumference=2*PI*r 
   Print "Circumference: "+Circumference
case 3:
   Area=PI*r*r 
   Print "Area:"+Area
Stop

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS