static void Main(string[] args) { Console.Title = "Math Facts App"; int choice = 0; Addition addTable = new Addition(); Multiplication timesTable = new Multiplication(); Division divisionTable = new Division(); do { MainAppTitle(); choice = MainMenu(); if (choice == 1) { bool continueChoice = true; int startNum = 0; int endNum = 0; do { addTable.AdditionTitle(); try { Console.WriteLine("Enter your starting number"); startNum = Int32.Parse(Console.ReadLine()); Console.WriteLine("Enter your ending number"); endNum = Int32.Parse(Console.ReadLine()); } catch (FormatException) { Console.WriteLine("Please enter a valid number"); Console.ReadLine(); } finally { if (startNum > 0 && endNum <= 10) { addTable.AdditionTitle(); Console.WriteLine(""); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("Your addition Table for {0} - {1}!", startNum, endNum); Console.WriteLine(""); addTable.AdditionTable(startNum, endNum); Console.WriteLine(""); try { Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine("Would you like more addition facts [y/n]?"); Console.ForegroundColor = ConsoleColor.White; string moreFacts = Console.ReadLine(); if (moreFacts == "y") { continueChoice = true; } else if (moreFacts == "n") { continueChoice = false; } } catch (Exception) { throw; } } } } while (continueChoice == true); } if (choice == 2) { bool continueChoice = true; int startNum = 0; int endNum = 0; do { timesTable.MultiplicationTitle(); try { Console.WriteLine("Enter your starting number."); startNum = Int32.Parse(Console.ReadLine()); Console.WriteLine("Enter your ending number."); endNum = Int32.Parse(Console.ReadLine()); } catch (Exception) { Console.WriteLine("Please enter a valid number."); Console.ReadLine(); } finally { if (startNum > 0 & endNum <= 10) { timesTable.MultiplicationTitle(); Console.WriteLine(""); Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("Your multiplication table for {0} - {1}.", startNum, endNum); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine(""); timesTable.MultiplicationTable(startNum, endNum); Console.WriteLine(""); try { Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine("Would you like more multiplication facts? [y/n]"); Console.ForegroundColor = ConsoleColor.White; string moreFacts = Console.ReadLine(); if (moreFacts == "y") { continueChoice = true; } else if (moreFacts == "n") { continueChoice = false; } } catch (Exception) { throw; } } } } while (continueChoice == true); } if (choice == 3) { bool continueChoice = true; int startNum = 0; int endNum = 0; do { divisionTable.DivisionTitle(); try { Console.WriteLine("Enter your starting number"); startNum = Int32.Parse(Console.ReadLine()); Console.WriteLine("Enter your ending number"); endNum = Int32.Parse(Console.ReadLine()); } catch (FormatException) { Console.WriteLine("Please enter a valid number"); Console.ReadLine(); } finally { if (startNum > 0 && endNum <= 10) { divisionTable.DivisionTitle(); Console.WriteLine(""); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("Your division Table for {0} - {1}!", startNum, endNum); Console.WriteLine(""); divisionTable.DivisionTable(startNum, endNum); Console.WriteLine(""); try { Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine("Would you like more division facts [y/n]?"); Console.ForegroundColor = ConsoleColor.White; string moreFacts = Console.ReadLine(); if (moreFacts == "y") { continueChoice = true; } else if (moreFacts == "n") { continueChoice = false; } } catch (Exception) { throw; } } } } while (continueChoice == true); } } while (choice != 4); }
static void Main(string[] args) //with static you don't need an instance to use a method { Console.Title = "Math Facts App"; int choice = 0; Addition addTable = new Addition(); Multiplication timesTable = new Multiplication(); do //Do While Loop for the whole program { MainAppTitle(); choice = MainMenu(); if (choice == 1) { bool continueChoice = true; int startNum = 0; int endNum = 0; do //Do While Loop for the Addition Class { addTable.AdditionTitle(); try //Try Catch for starting menu { Console.WriteLine("Enter your starting number"); startNum = Int32.Parse(Console.ReadLine()); Console.WriteLine("Enter your ending number"); endNum = Int32.Parse(Console.ReadLine()); } catch (FormatException) { Console.WriteLine("Please enter a valid number"); Console.ReadLine(); } finally { if (startNum > 0 && endNum <= 10) { addTable.AdditionTitle(); Console.WriteLine(""); Console.ForegroundColor = ConsoleColor.DarkGreen; Console.WriteLine("Your addition Table for {0} - {1}", startNum, endNum); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine(""); addTable.AdditionTable(startNum, endNum); Console.WriteLine(""); try { Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Would you like more additon facts [y/n]"); Console.ForegroundColor = ConsoleColor.White; string moreFacts = Console.ReadLine(); if (moreFacts == "y") { continueChoice = true; } else if (moreFacts == "n") { continueChoice = false; } } catch (Exception) { Console.WriteLine(""); Console.WriteLine("Enter y or n"); } } } } while (continueChoice == true); } //Multiplication portion if (choice == 2) { bool continueChoice = true; int startNum = 0; int endNum = 0; do //Do While Loop for the Multiplication Class { timesTable.MultiplicationTitle(); try { Console.WriteLine("Enter your starting number"); startNum = Int32.Parse(Console.ReadLine()); Console.WriteLine("Enter your ending number"); endNum = Int32.Parse(Console.ReadLine()); } catch (Exception) { Console.WriteLine("Please enter a valid number"); Console.ReadLine(); } finally { if (startNum > 0 & endNum <= 10) { timesTable.MultiplicationTitle(); Console.WriteLine(""); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Your Multiplication Table for {0} - {1}", startNum, endNum); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine(""); timesTable.MultiplicationTable(startNum, endNum); Console.WriteLine(""); try { Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Would you like more multiplication facts [y/n]"); Console.ForegroundColor = ConsoleColor.White; string moreFacts = Console.ReadLine(); if (moreFacts == "y") { continueChoice = true; } else if (moreFacts == "n") { continueChoice = false; } } catch (Exception) { Console.WriteLine(""); Console.WriteLine("Enter y or n"); } } } } while (continueChoice == true); } } while (choice != 3); }