// Method for Challenge 4 public static void ChallengeFour() { Console.WriteLine("You are now entering Challenge 4!\r\n"); // Variables for user input for temp conversion double temp1; double temp2; // Prompt user for F temp, validate, store, and create new object Console.Write("Please enter a temperature in Fahrenheit to be converted: "); temp1 = Validate.Temp(Console.ReadLine()); var newTemp1 = new TempConvert(temp1); // Give user feedback, convert tmep to Celsius, and tell user the new temp Console.WriteLine("The temperature you entered is {0} degrees Fahrenheit. That's {1} degrees Celsius!\r\n", newTemp1.GetTemp(), Math.Round(newTemp1.ConTempC(), 2)); // Prompt user for C temp, validate, store, and create new object Console.Write("Please enter a temperature in Celsius to be converted: "); temp2 = Validate.Temp(Console.ReadLine()); var newTemp2 = new TempConvert(temp2); // Give user feedback, convert tmep to Fahrenheit, and tell user the new temp Console.WriteLine("The temperature you entered is {0} degrees Celsius. That's {1} degrees Fahrenheit!\r\n", newTemp2.GetTemp(), Math.Round(newTemp2.ConTempF(), 2)); }
/* * Name: Christopher Westman * Date(YYMM): 1801 * Course: Project & Portfolio 1 * Synopsis: This is a code challenge for Development. This challenge contains five sub-challenges. * Every Challenge will be contained within its own class file. * Each challenge solves a unique problem that must be solved. All challenges use the Validate class which * contains several different types of validations. The validations can validate for word counts, single string inputs, * and numbers within a certain range or above -1. This main program file is simplified to only show the calling of * each challenge. To see the challenge code, simply open the class file with the name that mirrors the method call, * for example, ChallengeOne can be found in the SwapInfo class file. */ static void Main(string[] args) { // Challenge 1 SwapInfo.ChallengeOne(); // Challenge 2 Backwards.ChallengeTwo(); // Challenge 3 AgeConvert.ChallengeThree(); // Challenge 4 TempConvert.ChallengeFour(); // Challenge 5 MainMenu.ChallengeFive(); }
// Method for Challenge 5 public static void ChallengeFive() { Console.WriteLine("You are now entering Challenge 5!\r\n"); // Use while loop to allow menu prompt while (true) { // Variable for user entry double entry; // Prompt user to select from menu Console.WriteLine("Which challenge would you like to try again?\r\n" + "Enter 1 for SwapInfo\r\n" + "Enter 2 for Backwards\r\n" + "Enter 3 for AgeConvert\r\n" + "Enter 4 for TempConvert\r\n" + "Or enter 0 to quit"); // Validate and store user entry entry = Validate.Menu(Console.ReadLine()); // Cycle through if statement to start user menu option if (entry == 1) { SwapInfo.ChallengeOne(); } else if (entry == 2) { Backwards.ChallengeTwo(); } else if (entry == 3) { AgeConvert.ChallengeThree(); } else if (entry == 4) { TempConvert.ChallengeFour(); } else if (entry == 0) { // Break out of while loop if user doesn't want to run program Console.WriteLine("Exiting now! Thanks for using the program!"); break; } } }