Advertisement
Guest User

:P

a guest
Mar 30th, 2020
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.01 KB | None | 0 0
  1. using System;
  2. namespace Program
  3. {
  4.     class Program
  5.     {
  6.         static void Main(string[] args)
  7.         {
  8.             string choice;
  9.             double numberOne;
  10.             bool resultOne;
  11.             do
  12.             {
  13.                 Console.Write("Enter A:");
  14.                 resultOne = Double.TryParse(Console.ReadLine(), out numberOne);
  15.             }
  16.             while (!resultOne);
  17.             double numberTwo;
  18.             bool resultTwo;
  19.             do
  20.             {
  21.                 Console.Write("Enter B:");
  22.                 resultTwo = Double.TryParse(Console.ReadLine(), out numberTwo);
  23.             }
  24.             while (!resultTwo);
  25.             do
  26.             {
  27.                 Console.WriteLine("Methods: +, -, *, /, %");
  28.                 Console.Write("Choose method:");
  29.                 string method = Console.ReadLine();
  30.                 if (method == "+")
  31.                 {
  32.                     Console.WriteLine("Addition:" + (numberOne + numberTwo));
  33.                 }
  34.                 else if (method == "-")
  35.                 {
  36.                     Console.WriteLine("Substraction:" + (numberOne - numberTwo));
  37.                 }
  38.                 else if (method == "*")
  39.                 {
  40.                     Console.WriteLine("Multiplication:" + (numberOne * numberTwo));
  41.                 }
  42.                 else if (method == "/")
  43.                 {
  44.                     Console.WriteLine("Division:" + (numberOne / numberTwo));
  45.                 }
  46.                 else if (method == "%")
  47.                 {
  48.                     Console.WriteLine("Modulus:" + (numberOne % numberTwo));
  49.                 }
  50.                 else
  51.                     Console.WriteLine("Not existing method. Error 404.");
  52.                 Console.WriteLine("To continue choose different method.");
  53.                 Console.WriteLine("To quit type exit.");
  54.                 choice = Console.ReadLine();
  55.             }
  56.                 while(!choice.Equals("exit"));
  57.             {
  58.             }
  59.         }
  60.     }    
  61.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement