Advertisement
EvenGuy

Площадь круга на C#

Sep 30th, 2016
1,015
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.34 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApplication9
  8. {
  9.     class MyMathOper
  10.     {
  11.         public double r;
  12.         public string s;
  13.  
  14.         public double sqrCircle()
  15.         {
  16.             return Math.PI * (r * r);
  17.         }
  18.  
  19.         public double longCircle()
  20.         {
  21.             return 2 * Math.PI * r;
  22.         }
  23.  
  24.         public void WriteResult()
  25.         {
  26.             Console.Write("Вычислить S или L? ");
  27.  
  28.             s = Console.ReadLine();
  29.             s = s.ToLower();
  30.  
  31.             if (s == "s")
  32.             {
  33.                 Console.WriteLine("S круга = " + sqrCircle());
  34.                 return;
  35.             }
  36.             else if (s == "l")
  37.             {
  38.                 Console.WriteLine("L круга = " + longCircle());
  39.                 return;
  40.             }
  41.             else
  42.                 Console.WriteLine("Неверно");
  43.         }
  44.     }
  45.  
  46.     class Program
  47.     {
  48.         static void Main(string[] args)
  49.         {
  50.             Console.Write("Введите радиус: ");
  51.             string rad = Console.ReadLine();
  52.  
  53.             MyMathOper newOper = new MyMathOper { r = double.Parse(rad)};
  54.  
  55.             newOper.WriteResult();
  56.             Console.ReadLine();
  57.         }
  58.     }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement