SHARE
TWEET

Untitled

a guest Jun 17th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace SimpleCalculator
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             //use for the string operation choice
  14.             int operation = 0;
  15.             //stock the result of the operation
  16.             double result = 0;
  17.             string operationstring = "";
  18.             //Ask user first number
  19.             Console.WriteLine("Type you first number :");
  20.             double firstNumber = Convert.ToDouble(Console.ReadLine());
  21.  
  22.             //Ask user second number
  23.             Console.WriteLine("Type you second number :");
  24.             double secondNumber = Convert.ToDouble(Console.ReadLine());
  25.  
  26.             //Ask user operation to use
  27.             Console.WriteLine("Enter the operation + (Add to each other ), - (Substraction), * (Multiplication), / (Division), ^ (Exposent) ");
  28.             string stringOperation = Console.ReadLine();
  29.  
  30.             // Convert string choice to integral
  31.             switch (stringOperation[0])
  32.             {
  33.                 case '+':
  34.                     result = firstNumber + secondNumber;
  35.                     operationstring = "Addition";
  36.                     break;
  37.                 case '-':
  38.                     result = firstNumber - secondNumber;
  39.                     operationstring = "Substraction";
  40.                     break;
  41.                 case '/':
  42.                     result = firstNumber / secondNumber;
  43.                     operationstring = "Divsion";
  44.                     break;
  45.                 case '*':
  46.                     result = firstNumber * secondNumber;
  47.                     operationstring = "Multiply";
  48.                     break;
  49.                 case '^':
  50.                     result = Math.Pow(firstNumber, secondNumber);
  51.                     operationstring = "Exposent";
  52.                     break;
  53.             }
  54.  
  55.  
  56.  
  57.             //Do someting depending on the operation choose
  58.      
  59.             Console.WriteLine("\nResult of " + firstNumber + " " + operationstring + " " + secondNumber + " = " + result + ".");
  60.             Console.ReadKey();
  61.         }
  62.     }
  63. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top