//public static string ValidateStringInput() //{ // while (String.IsNullOrWhiteSpace(inputString)) // { // Console.WriteLine("Please enter a Valid number"); // inputString = Console.ReadLine(); // } // return inputString; //} public static void UserSelction(string inputString) { if (inputString == "1") { Console.WriteLine("OK, what temperature in Fahrenheit would you like to convert?"); convertString = Console.ReadLine(); FahrenheitToCelsius(); } else if (inputString == "2") { Console.WriteLine("OK, what temperature in Celsius would you like to convert?"); convertString = Console.ReadLine(); CelsiusToFahrenheit(); } else if (inputString == "3") { Console.WriteLine("OK, what temperature in Fahrenheit would you like to convert?"); convertString = Console.ReadLine(); FahrenheitToKelvin(); } else if (inputString == "4") { Console.WriteLine("OK, what temperature in Celsius would you like to convert?"); convertString = Console.ReadLine(); CelsiusToKelvin(); } else { //invalid input. re-Ask Console.WriteLine("Please Enter a valid number"); inputString = Console.ReadLine(); CE7_Validation.ValidateStringInput(); UserSelction(inputString); } }
// Public, Static methods are available to the entire solution. public static void Display() { Console.Clear(); //Ask which challenge they would like to attempt Console.WriteLine("Coding Challenge Menu:\r\nPlease enter the number for the challenge you want to run..." + "\r\n[1] Swap Name \r\n[2] Backwards \r\n[3] Age Convert \r\n[4] Temp Convert \r\n[5] Big Blue Fish \r\n[0] Exit"); CE7_Validation.inputString = Console.ReadLine(); CE7_Validation.ValidateStringInput(); inputString = CE7_Validation.inputString; UserSelction(inputString); }
public static void TempConvertTest() { Console.WriteLine(" Welcome to TempConvert.Would you like to...\r\n " + "1.Convert temperature from Fahrenheit to Celsius \r\n " + "2.Convert temperature from Celsius to Fahrenheit \r\n " + "3.Convert temperature from Fahrenheit to Kelvin \r\n " + "4.Convert temperature from Celsius to Kelvin"); inputString = Console.ReadLine(); CE7_Validation.ValidateStringInput(); UserSelction(inputString); Console.WriteLine("Please press enter to return to the Main Menu"); Console.ReadLine(); //return to menu CE1_Menu.Display(); }
public static void UserSelction(string inputString) { if (inputString == "1") { Console.WriteLine("Opening Swap Name Coding Challenge"); CE2_SwapName.SwapNameTest(); //run CE2_SwapName } else if (inputString == "2") { Console.WriteLine("Opening Backwards Coding Challenge"); //run CE3_Backwards CE3_Backwards.BackwardsTest(); } else if (inputString == "3") { Console.WriteLine("Opening Age Convert Coding Challenge"); //run CE4_AgeConvert CE4_AgeConvert.AgeConvertTest(); } else if (inputString == "4") { Console.WriteLine("Opening Temp Convert Coding Challenge"); //run CE5_TempConvert CE5_TempConvert.TempConvertTest(); } else if (inputString == "5") { Console.WriteLine("Opening Big Blue Fish Coding Challenge"); //run CE6_BigBlueFish CE6_BigBlueFish.BigBlueFishTest(); } else if (inputString == "0") { Console.WriteLine("Closing Coding Challenge"); //terminate program } else { //invalid input. re-Ask Console.WriteLine("Please Enter a valid number"); inputString = Console.ReadLine(); CE7_Validation.ValidateStringInput(); UserSelction(inputString); } }
public static void AgeConvertTest() { //Ask for users name Console.WriteLine(" Welcome to AgeConvert:\r\n To begin, please enter your name...\r\n"); inputString = Console.ReadLine(); //Validate name CE7_Validation.ValidateStringInput(); myName = inputString; //Ask for users birth month Console.WriteLine("Thank you " + myName + ". Now I know this may be personal, but what's your age? \r\n Please enter the numerical month of your birth and press enter"); inputString = Console.ReadLine(); //Validate Int. need an extra check for length of int. CE7_Validation.ValidateIntInput(); birthMonth = int.Parse(inputString); Console.WriteLine("Birth Month is " + birthMonth); //Ask for birth month Console.WriteLine("Thank you " + myName + ". \r\n Please enter the numerical day of your birth and press enter"); inputString = Console.ReadLine(); //Validate input need an extra check for length of int. CE7_Validation.ValidateIntInput(); birthDay = int.Parse(inputString); Console.WriteLine("Birth Day is " + birthDay); //Ask for birth year Console.WriteLine("Thank you " + myName + ". \r\n Please enter the numerical year of your birth and press enter"); inputString = Console.ReadLine(); CE7_Validation.ValidateIntInput(); birthYear = int.Parse(inputString); Console.WriteLine("Birth year is " + birthYear); //give all arguments a value to make Date time work birthours = 0; birthMinutes = 0; birthSeconds = 0; DateTime myBrithday = new DateTime(birthYear, birthMonth, birthDay, birthours, birthMinutes, birthSeconds); //order //23 DateTime DoB = Convert.ToDateTime(myBrithday); string text = MyAgeSimplified(DoB); Console.WriteLine("Fantastic! Next time someone asks, try answering with:" + MyAgeSimplified(DoB) + "-OR-"); MyAgeUnSimplified(); Console.WriteLine("Please press enter to return to the Main Menu"); Console.ReadLine(); //return to menu CE1_Menu.Display();
public static void SwapNameTest() { //Prompt the user for their first and last names(separately) Console.WriteLine("Welcome to SwapName: \r\nTo begin, please enter your first name..."); CE7_Validation.ValidateStringInput(); inputString = Console.ReadLine(); string firstName = inputString; // Each time data is entered save and display the information Console.WriteLine("Thank you " + firstName + ", now I will need your last name..."); inputString = Console.ReadLine(); CE7_Validation.ValidateStringInput(); string lastName = inputString; // Each time data is entered save and display the information Console.WriteLine("Excellent! Your name " + firstName + " " + lastName + " reversed would be " + (SwapNameTest(firstName, lastName))); Console.WriteLine("Please press enter to return to the Main Menu"); Console.ReadLine(); //return to menu CE1_Menu.Display(); }