static void Main(string[] args) { Arithmetic a1 = new Arithmetic(); a1.Addition(); a1.Subtraction(); a1.Multiplication(); a1.Division(); Console.ReadKey(); }
static void Main(string[] args) { Arithmetic arth = new Arithmetic(); arth.GetData(); arth.getSum(); arth.getSub(); arth.getProd(); arth.getDiv(); }
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; } }