Answer to Question #259973 in C# for Scott

Question #259973

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

Triangle, Oval, Trapezium, Hexagon, Circle, Pentagon, Cone, Decagon in windows form


Create a Midi Parent form



1
Expert's answer
2021-11-02T08:53:38-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