Advertisement
ilian_test

Untitled

Oct 11th, 2020 (edited)
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.27 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _06._Area_of_Figures
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string input = Console.ReadLine();
  10.  
  11.             if (input == "square")
  12.             {
  13.                 double a = double.Parse(Console.ReadLine());
  14.                 double S = a * a;
  15.                 Console.WriteLine(Math.Round(S, 3).ToString("0.000"));
  16.             }
  17.             else if (input == "rectangle")
  18.             {
  19.                 double a = double.Parse(Console.ReadLine());
  20.                 double b = double.Parse(Console.ReadLine());
  21.                 double S = a * b;
  22.                 Console.WriteLine(Math.Round(S, 3).ToString("0.000"));
  23.             }
  24.             else if (input == "circle")
  25.             {
  26.                 double r = double.Parse(Console.ReadLine());
  27.                 double x = Math.PI * r * r;
  28.                 Console.WriteLine(Math.Round(x, 3).ToString("0.000"));
  29.             }
  30.             else if (input == "triangle")
  31.             {
  32.                 double a = double.Parse(Console.ReadLine());
  33.                 double b = double.Parse(Console.ReadLine());
  34.                 double S = (a * b) / 2;
  35.                 Console.WriteLine(Math.Round(S, 3).ToString("0.000"));
  36.             }
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement