A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

Write a program in C# Sharp which is a Menu-Driven Program to compute the area of the various geometrical shape
Q:

Write a program in C# Sharp which is a Menu-Driven Program to compute the area of the various geometrical shape

0

Write a program in C# Sharp which is a Menu-Driven Program to compute the area of the various geometrical shape

Sample Output:

A menu driven program to compute the area of various geometrical shape:                                       
-------------------------------------------------------------------------                      
Input 1 for area of circle                                                                                    
Input 2 for area of rectangle                                                                                 
Input 3 for area of triangle                                                                                  
Input your choice : 2                                                                                         
Input length  of the rectangle : 20                                                                           
Input  width of the rectangle : 30                                                                            
The area is : 600

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

using System;  
public class Exercise24  
{  
    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 an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now