static void Main(string[] args) { DisplayMessage("\nHello and welcome to my Calculator Assignment with classes!"); Console.ReadKey(); AskUserForNumbers.AskUserForNumberOne(); }
public static void Multi(double firstNumber, char operater) { double multiSecond = AskUserForNumbers.AskUserForNumberTwo(firstNumber, operater); double result = firstNumber * multiSecond; Result.ResultValue(result); }
public static void Sub(double firstNumber, char operater) { try { double subSecond = AskUserForNumbers.AskUserForNumberTwo(firstNumber, operater); double result = firstNumber - subSecond; Result.ResultValue(result); UserChoices.SubtractionContinuation(result); } catch (Exception) { Program.DisplayMessage("\nPlease try again", ConsoleColor.Red); } }
public static void Add(double firstNumber, char operater) { try { double addFirst = firstNumber; double addSecond = AskUserForNumbers.AskUserForNumberTwo(firstNumber, operater); double result = addFirst + addSecond; Result.ResultValue(result); UserChoices.AdditionContinuation(result); } catch (Exception) { Program.DisplayMessage("\nSomething went wrong. Please try again", ConsoleColor.Red); } }
public static void SubLoop(double result) { try { char choice = '-'; double subThird = AskUserForNumbers.AskUserForNumberTwo(result, choice); result -= subThird; Result.ResultValue(result); UserChoices.SubtractionContinuation(result); } catch (Exception) { Program.DisplayMessage("\nSomething went wrong. Please try again!", ConsoleColor.Red); } }
public static void AddLoop(double result) { try { char operater = '+'; double addThird = AskUserForNumbers.AskUserForNumberTwo(result, operater); result += addThird; Result.ResultValue(result); UserChoices.AdditionContinuation(result); } catch (Exception) { Program.DisplayMessage("\nSomething went wrong. Please try again", ConsoleColor.Red); } }
public static void Div(double firstNumber, char operater) { double divFirst = 0; try { if (firstNumber == 0) { Program.DisplayMessage("\nYou cannot divide by 0. You will therefore have to repick your wanted numbers", ConsoleColor.Red); Console.ReadKey(); divFirst = AskUserForNumbers.AskUserForDivisionNumber(); firstNumber = divFirst; } double divSecond = AskUserForNumbers.AskUserForDivisionNumber(); double result = firstNumber / divSecond; Result.ResultValue(result); } catch (Exception) { Program.DisplayMessage("\nSomething went wrong. Please try again", ConsoleColor.Red); } }
public static int CalculatorContinuation() { bool stayAlive = true; int usefulNumber = 0; do { try { Program.DisplayMessage("\n\nWould you like to continue using the calculator? y/n: "); char continuationChoice = char.ToUpper(Console.ReadKey(true).KeyChar); stayAlive = false; switch (continuationChoice) { case 'Y': Console.Clear(); AskUserForNumbers.AskUserForNumberOne(); break; case 'N': stayAlive = false; break; default: throw new Exception(); } } catch (Exception) { Program.DisplayMessage("\nSomething went wrong, please try again.", ConsoleColor.Red); } } while (stayAlive); return(usefulNumber); }