Advertisement
Guest User

Untitled

a guest
Jan 20th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.81 KB | None | 0 0
  1. using System;
  2.                    
  3. public class Program
  4. {
  5.     public static void Main()
  6.     {
  7.         string figuretype = Console.ReadLine();
  8.         double area = 0.0;
  9.        
  10.        
  11.         switch (figuretype)
  12.         {
  13.             case "square":
  14.         {
  15.             double a = double.Parse(Console.ReadLine());
  16.             area = a*a;
  17.               break;       
  18.         }
  19.         case "rectangle":
  20.         {
  21.             double a = double.Parse(Console.ReadLine());
  22.             double b = double.Parse(Console.ReadLine());
  23.                 area = a*b;
  24.               break;       
  25.         }
  26.                
  27.                 case "circle":
  28.                 {
  29.                 double radius = int.Parse(Console.ReadLine());
  30.                 area = Math.PI * radius * radius;
  31.                 break;
  32.                 }
  33.        
  34.         case "triangle":
  35.         {
  36.             double side = double.Parse(Console.ReadLine());
  37.             double hight = double.Parse(Console.ReadLine());
  38.             area = side * hight / 2 ;
  39.               break;       
  40.         }
  41.     }
  42.         Console.WriteLine($"{area:F3}");
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement