static void Main(string[] args) { String choice; Arithmetic a = new Arithmetic(); Console.WriteLine("Enter 1:Addition; 2: Subtraction; 3:Multiplication; 4:Division"); choice = Console.ReadLine(); switch (choice) { case "1": a.Addition(); break; case "2": a.Subtraction(); break; case "3": a.Multiplication(); break; case "4": a.Division(); break; default: Console.WriteLine("Wrong input"); break; } }
static void Main(string[] args) { Console.WriteLine("Please enter operation..."); string operation = Console.ReadLine(); Arithmetic a1 = new Arithmetic(); switch (operation) { case "Addition": a1.Addition(); break; case "Subtraction": a1.Subtraction(); break; case "Multiplication": a1.Multiplication(); break; case "Division": a1.Division(); break; } }
static void Main(string[] args) { //Console.WriteLine("Hello World!"); Arithmetic a1 = new Arithmetic(); a1.GetNumber(); Console.WriteLine("Choose\n1: Addition\n2: Subtraction\n3: Multiplication\n4: Division"); int caseSwitch = Convert.ToInt32(Console.ReadLine()); switch (caseSwitch) { case 1: Console.WriteLine(a1.Addition()); break; case 2: Console.WriteLine(a1.Subtraction()); break; case 3: Console.WriteLine(a1.Multiplication()); break; case 4: Console.WriteLine(a1.Division()); break; default: break; } }
static void Main(string[] args) { Arithmetic a1 = new Arithmetic(); a1.Addition(); a1.Subtraction(); a1.Multiplication(); a1.Division(); Console.ReadKey(); }
static void Main(string[] args) { int inputA; int inputB; //accept input data //int result; //store output data string arithmetic; //decide which arithmetic to use //Get input datas Console.Write("Please input the first number: "); inputA = Convert.ToInt32(Console.ReadLine()); Console.Write("\nPlease input the second number: "); inputB = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("\nPlease input the arithmetic you want to compute: "); Console.WriteLine("\nInput A for addition, S for subtraction, D for division, M for multiplication"); arithmetic = Console.ReadLine(); Arithmetic buf = new Arithmetic(inputA, inputB); //Create an instance of Arithmetic //Use switch to decide which operation to do switch (arithmetic) { case "A": Console.WriteLine("{0}", buf.Addition()); break; case "S": Console.WriteLine("{0}", buf.Subtraction()); break; case "D": Console.WriteLine("{0}", buf.Division()); break; case "M": Console.WriteLine("{0}", buf.Multiplication()); break; default: Console.WriteLine("Incorrect input, please try again"); break; } Console.WriteLine("Press any key to exit"); Console.ReadKey(); }
static void Main(string[] args) { int option; Arithmetic a1 = new Arithmetic(); a1.GetA(); a1.GetB(); a1.DisplayOptions(); System.Console.Write("Enter the Arithmetic Operation number: "); option = Convert.ToInt32(System.Console.ReadLine()); switch (option) { case 1: System.Console.WriteLine($"Result: {a1.Addition()}"); break; case 2: System.Console.WriteLine($"Result: {a1.Subtraction()}"); break; case 3: System.Console.WriteLine($"Result: {a1.Multiplication()}"); break; case 4: System.Console.WriteLine($"Result: {a1.Division()}"); break; default: Console.WriteLine($"An unexpected option selected: ({option})"); break; } }