Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace SimpleCalculator
- {
- class Program
- {
- static void Main(string[] args)
- {
- //use for the string operation choice
- int operation = 0;
- //stock the result of the operation
- double result = 0;
- string operationstring = "";
- //Ask user first number
- Console.WriteLine("Type you first number :");
- double firstNumber = Convert.ToDouble(Console.ReadLine());
- //Ask user second number
- Console.WriteLine("Type you second number :");
- double secondNumber = Convert.ToDouble(Console.ReadLine());
- //Ask user operation to use
- Console.WriteLine("Enter the operation + (Add to each other ), - (Substraction), * (Multiplication), / (Division), ^ (Exposent) ");
- string stringOperation = Console.ReadLine();
- // Convert string choice to integral
- switch (stringOperation[0])
- {
- case '+':
- result = firstNumber + secondNumber;
- operationstring = "Addition";
- break;
- case '-':
- result = firstNumber - secondNumber;
- operationstring = "Substraction";
- break;
- case '/':
- result = firstNumber / secondNumber;
- operationstring = "Divsion";
- break;
- case '*':
- result = firstNumber * secondNumber;
- operationstring = "Multiply";
- break;
- case '^':
- result = Math.Pow(firstNumber, secondNumber);
- operationstring = "Exposent";
- break;
- }
- //Do someting depending on the operation choose
- Console.WriteLine("\nResult of " + firstNumber + " " + operationstring + " " + secondNumber + " = " + result + ".");
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement