static void Main(string[] args) { try { Console.WriteLine("Enter the first Number"); double firstNumber = InputFormatter.FormatNumber(Console.ReadLine()); Console.WriteLine("Enter the second Number"); double secondNumber = InputFormatter.FormatNumber(Console.ReadLine()); Console.WriteLine("Enter the operator"); //string op = InputFormatter.FormatOperator(Console.ReadLine()); string op = Console.ReadLine(); //double result = Calculator.Calculate(firstNumber, secondNumber, op); Console.WriteLine(op.Getresult(firstNumber, secondNumber)); //Console.WriteLine(result); } catch (Exception ex) { Console.WriteLine(string.Format("Exception encountered while performing calculation. Error: {0}", ex.Message)); } finally { Console.ReadKey(); } }
static void Main(string[] args) { try { Console.WriteLine("Enter the first Number"); double firstNumber = InputFormatter.FormatNumber(Console.ReadLine()); Console.WriteLine("Enter the second Number"); double secondNumber = InputFormatter.FormatNumber(Console.ReadLine()); Console.WriteLine("Enter the operator"); string op = InputFormatter.FormatOperator(Console.ReadLine()); //Adding logic to swap the values if firstNumber < secondNumber ValueSequencer.GetNumberOrder(ref firstNumber, ref secondNumber); double result = Calculator.Calculate(firstNumber, secondNumber, op); Console.WriteLine(result); } catch (Exception ex) { Console.WriteLine(string.Format("Exception encountered while performing calculation. Error: {0}", ex.Message)); } finally { Console.ReadKey(); } }
private static void Main() { string choice = "n"; do { try { Console.WriteLine("Enter the first Number"); double firstNumber = InputFormatter.FormatNumber(Console.ReadLine()); Console.WriteLine("Enter the second Number"); double secondNumber = InputFormatter.FormatNumber(Console.ReadLine()); Console.WriteLine("Enter the operator"); string op = InputFormatter.FormatOperator(Console.ReadLine()); double result = Calculator.Calculate(firstNumber, secondNumber, op); Console.WriteLine("The output of the operation is {0}", result); } catch (Exception ex) { Console.WriteLine(string.Format("Exception encountered while performing calculation. Error: {0}", ex.Message)); } finally { Console.WriteLine("Do you want to continue(y/n)?"); choice = Console.ReadLine().ToLower(); while (choice != "y" && choice != "n") { Console.WriteLine("Do you want to continue(y/n)?"); choice = Console.ReadLine().ToLower(); } } } while (choice == "y"); }
static void Main(string[] args) { try { Console.WriteLine("Enter the first Number"); double firstNumber = InputFormatter.FormatNumber(Console.ReadLine()); Console.WriteLine("Enter the second Number"); double secondNumber = InputFormatter.FormatNumber(Console.ReadLine()); Console.WriteLine("Enter the operator from the list: +, -, /, *, %, s = squ, R = squareroot, i = sin , t =tan ,c =cos "); string op = InputFormatter.FormatOperator(Console.ReadLine()); double result = Calculator.Calculate(firstNumber, secondNumber, op); Console.WriteLine(result); } catch (Exception ex) { Console.WriteLine(string.Format("Exception encountered while performing calculation. Error: {0}", ex.Message)); } finally { Console.ReadKey(); } }