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 VisualStudioDisplay
- {
- class Program
- {
- static void Main(string[] args)
- {
- int one = 0;
- int two = 0;
- while (true)
- {
- printMenu();
- string input = getInput(false);
- switch (input)
- {
- case "1":
- print("Enter Number 1: ");
- one = Convert.ToInt32(getInput());
- print("Enter Number 2: ");
- two = Convert.ToInt32(getInput());
- print("The answer is " + Add(one, two));
- break;
- case "2":
- print("Enter Number 1: ");
- one = Convert.ToInt32(getInput());
- print("Enter Number 2: ");
- two = Convert.ToInt32(getInput());
- print("The answer is " + Subtract(one, two));
- break;
- case "Q":
- case "q":
- return;
- }
- }
- }
- static void print(string s)
- {
- Console.WriteLine(s);
- }
- static void printMenu()
- {
- print("1. Add");
- print("2. Substract");
- print("Q. Quit");
- }
- static string getInput(bool line = true)
- {
- if(line)
- {
- return Console.ReadLine();
- }
- else
- {
- string input = Console.ReadKey().KeyChar.ToString();
- Console.WriteLine();
- return input;
- }
- }
- static int Add(int one, int two)
- {
- return one + two;
- }
- static int Subtract(int one, int two)
- {
- return one - two;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement