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.
Use the switch statement. The program is to ask for the radius of a circle. Present the menu and execute the corresponding calculation.
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
Comments
Leave a comment