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 ConsoleApplication14
- {
- class Program
- {
- static void Main(string[] args)
- {
- //calculator
- string exit = ".";
- while (exit != "exit" && exit != "close")
- {
- Console.WriteLine("Enter two numbers:");
- double num1 = double.Parse(Console.ReadLine());
- double num2 = double.Parse(Console.ReadLine());
- Console.WriteLine("Please choose operator (*, /, +, -):");
- string op = Console.ReadLine();
- switch (op)
- {
- case ("*"):
- Console.WriteLine(num1 * num2);
- break;
- case ("/"):
- Console.WriteLine(num1 / num2);
- break;
- case ("+"):
- Console.WriteLine(num1 + num2);
- break;
- case ("-"):
- Console.WriteLine(num1 - num2);
- break;
- default:
- Console.WriteLine("Invalid operator!");
- break;
- }
- Console.WriteLine("Type 'exit' or 'close' in order to exit the program. If you would like to\nchoose again, press enter.");
- exit = Console.ReadLine();
- Console.WriteLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement