Answer to Question #255009 in C# for Scott

Question #255009

Create a menu to calculate the area and perimeter of different figures

a)Triangle        e)Oval

b)Trapezium    f)Hexagon

c)Circle           g)Pentagon

d))Cone           h)Decagon


Create a Midi Parent form

Progress bar/Slash Screen



1
Expert's answer
2021-10-22T04:53:45-0400
using System;  
public class Exercise  
{  
    public static void Main()
{
      int choice,r,l,w,b,h;
      double area=0;

           Console.Write("\n\n");
           Console.Write("A menu driven program to compute the area of various geometrical shape:\n");
           Console.Write("-------------------------------------------------------------------------");
           Console.Write("\n\n");


      Console.Write("Input 1 for area of circle\n");
      Console.Write("Input 2 for area of rectangle\n");
      Console.Write("Input 3 for area of triangle\n");
      Console.Write("Input your choice : ");
      choice = Convert.ToInt32(Console.ReadLine());

      switch(choice)
      {
           case 1:
                 Console.Write("Input radius of the circle : ");
                 r = Convert.ToInt32(Console.ReadLine());
                    area=3.14*r*r;
                 break;
            case 2:
                  Console.Write("Input length  of the rectangle : ");
                  l = Convert.ToInt32(Console.ReadLine());
                  Console.Write("Input  width of the rectangle : ");
                  w = Convert.ToInt32(Console.ReadLine());
                  area=l*w;
                  break;
            case 3:
                  Console.Write("Input the base of the triangle :");
                  b = Convert.ToInt32(Console.ReadLine());
                  Console.Write("Input the hight of the triangle :");
                  h = Convert.ToInt32(Console.ReadLine());
                         area=.5*b*h;
                  break;
          }
          Console.Write("The area is : {0}\n",area);
    }
}

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