Write a program in C#, that will have a main menu that contains three options to
ID: 3691486 • Letter: W
Question
Write a program in C#, that will have a main menu that contains three options to choose from: Perimeter, Area and Volume. These three options will then prompt you to another menu regarding the selected option. In Perimeter, the program will let the user choose between: Square, Rectangle, Triangle and Circle. In Area, it will calculate: Square, Rectangle, Triangle and Circle. The objective of this program is a user-friendly program to will let the user choose different geometrical figures to be calculated accordingly. It is not necessary to complete the entire program, just the menu and the perimeter part and I will take care of the rest. (Doing that, I will finish it guiding myself with your work). Thank you very much.
Explanation / Answer
here is the code you required:
using System.IO;
using System;
namespace Geometry
class Program
{
static void Main()
{
Console.WriteLine("Enter your choice:Menu:");
Console.WriteLine("1.Perimeter 2.Area 3.Volume 4.exit");
string choice=Console.ReadLine();
switch(choice)
{
case "Perimeter":Console.WriteLine("choose the Geometrical Figure");
Console.WriteLine("1.Square 2.Rectangle 3.triangle 4.Circle");
string choice2=Console.ReadLine();
switch(choice2)
{
case "Square":Console.WriteLine("Enter any side: ");
int a=Console.ReadLine();
Console.WriteLine("the perimeter of the square:",4*a);
break;
case "Rectangle":Console.WriteLine("Enter length: ");
int a=Console.ReadLine();
Console.WriteLine("Enter width: ");
int b=Console.ReadLine();
Console.WriteLine("the perimeter of the rectangle:",2*(a+b));
break;
case "Triangle":Console.WriteLine("Enter side1: ");
int a=Console.ReadLine();
Console.WriteLine("Enter side2: ");
int b=Console.ReadLine();
Console.WriteLine("Enter side3: ");
int c=Console.ReadLine();
Console.WriteLine("the perimeter of the triangle:",a+b+c);
break;
case "Circle":Console.WriteLine("Enter Radius:");
int r=Console.ReadLine();
Console.WriteLine("the circumference of a circle:",2*3.414*r);
break;
default:Console.WriteLine("Invalid Input");
}
break;
case "Area":
case "Volume":
case "exit":exit(0);
}
}
}
the code contains nested switch. which would repeat for area and volume also.
as the code is pseudo the output is not included.
for further queries kindly get back
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.