/// <summary> /// This is a run method containing some the class methods in a single method. /// I am calling my class methods in this method and adding some Console.WriteLine /// code so the datais outputted for the user to see. /// Furthermore I have storedsome methods inside some variables. /// I have added a do while to restart the program if the user wants. /// </summary> public void Run() { string restart; do { ConsoleHelper.OutputHeading("Distance Converter"); Console.WriteLine("Select distance to convert from > "); string input = InputChoices(); FromUnit = SelectChoice(input); Console.WriteLine($"\nYou have selected {FromUnit}"); Console.WriteLine("\nSelect distance to convert into > "); string input2 = InputChoices(); ToUnit = SelectChoice(input2); Console.WriteLine($"\nYou have selected {ToUnit}"); Console.WriteLine($"\nConverting {FromUnit} to {ToUnit}"); Console.Write($"\nEnter distance in {FromUnit} > "); InputDistance = InputData(); CalculateDistance(); Console.WriteLine("Would you like to restart the program: Yes/No"); restart = Console.ReadLine().ToLower(); }while (restart == "yes"); { Console.WriteLine("Thank you for using the Distance Converter"); } }
/// <summary> /// This is the main method that will be called as soon as /// Distance converter runs /// </summary> public void Run() { ConsoleHelper.OutputHeading("Distance Converter App"); ConvertDistance(); }
/// <summary> /// Asks the user to input a distance, which is then converted into the unit /// they selected at the start, and the result is /// displayed on-screen. /// </summary> public void ConvertDistance() { ConsoleHelper.OutputHeading("Distance Conversion Calculator"); FromUnit = SelectUnit("From Unit"); ToUnit = SelectUnit("To Unit"); /// If the user has selected the From and To units with the same /// choice, an error message will appear and will keep doing so /// until they choose a different To unit. while (ToUnit == FromUnit) { Console.WriteLine("\tThe To unit cannot be the same as " + "the From unit. Please try again.\n"); ToUnit = SelectUnit("To Unit"); } Console.WriteLine($"\t{FromUnit} -> {ToUnit} Conversion"); FromDistance = ConsoleHelper.InputNumber($"\tPlease enter the number of {FromUnit} > "); CalculateDistance(); OutputDistance(); ExitDecision(); }
/// <summary> /// This method will input a distance then calculate /// the same distance in the chosen measurement then /// output the results to the user. /// </summary> public void ConvertDistance() { ConsoleHelper.OutputHeading("Distance Converter"); Boolean finished = false; while (!finished) { FromUnit = null; ToUnit = null; FromUnit = SelectUnit(" Please select the from distance unit >"); ToUnit = SelectUnit(" Please select the to distance unit >"); Console.WriteLine($"\n Converting {FromUnit} to {ToUnit}"); FromDistance = InputDistance($" Please enter the number of {FromUnit} > "); CalculateDistance(); OutputDistance(); finished = QuitApplication(); } Console.WriteLine("Application Finshed"); }
/// <summary> /// This method will Input the distance in miles /// calculate the same distance in feet, and output the /// distance in feet. /// </summary> public void ConvertDistance() { string[] choices = new string[] { FEET, METERS, MILES }; int choice; Console.WriteLine("Select the distance unit to convert from >"); choice = ConsoleHelper.SelectChoice(choices); FromUnit = ExecuteChoice(choice); if (choice == 1) { Console.WriteLine("You have selected Feet"); } else if (choice == 2) { Console.WriteLine("You have selected Meters"); } else if (choice == 3) { Console.WriteLine("You have selected Miles"); } Console.WriteLine("Select the distance unit to convert to >"); choice = ConsoleHelper.SelectChoice(choices); ToUnit = ExecuteChoice(choice); if (choice == 1) { Console.WriteLine("You have selected Feet"); } else if (choice == 2) { Console.WriteLine("You have selected Meters"); } else if (choice == 3) { Console.WriteLine("You have selected Miles"); } ConsoleHelper.OutputHeading($"Converting {FromUnit} to {ToUnit}"); FromDistance = ConsoleHelper.InputNumber($"Please enter the number of {FromUnit} > "); CalculateDistance(); OutputDistance(); }
/// <summary> /// This method will run the program, outputting a heading /// and closing the program if the user does not wish to /// chose to convert another distance /// </summary> public void Run() { bool repeat = true; while (repeat) { ConsoleHelper.OutputHeading(" Distance Converter"); ConvertDistance(); repeat = ConsoleHelper.WantToRepeat(); } }
public void ConvertDistance() { ConsoleHelper.OutputHeading("Distance Converter", 0.6); FromUnit = SelectUnit(" Please select the 'from' distance unit: "); ToUnit = SelectUnit(" Please select the 'to' distance unit: "); Console.WriteLine($"\n Convert {FromUnit} to {ToUnit}"); FromDistance = InputDistance($" Please enter the number of {FromUnit}: "); CalculateDistance(); OutputDistance(); }
/// <summary> /// Call other methods /// Prompts the user to input which unit the distance which will be converted from /// and which unit it will be converted to. /// </summary> public void ConvertDistance() { ConsoleHelper.OutputHeading("Distance Converter"); FromUnit = SelectUnit("Please select the from distance unit > "); ToUnit = SelectUnit("Please select the to distance unit > "); Console.WriteLine($"Converting {FromUnit} to {ToUnit}\n"); FromDistance = ConsoleHelper.InputNumber($"Please enter the number of {FromUnit} > "); CalculateDistance(); OutputDistance(); }
/* * Recieves user input for amount of miles the user wishes to convert. * Input must be given as a double number */ public void ConvertingDistance() { ConsoleHelper.OutputHeading("Distance Converter"); FromUnit = SelectUnit("\nPlease enter the unit you wish to convert: "); ToUnit = SelectUnit("\nPlease enter the unit you wish to convert: "); Console.WriteLine($"\nConverting {FromUnit} to {ToUnit}"); FromDistance = InputDistance($" \nPlease input the number of {FromUnit}: "); CalculateDistance(); OutputDistance(); }
/// <summary> /// Here this method will change the Distance from Miles to Feet. /// </summary> public void ConvertDistance() { ConsoleHelper.OutputHeading("Distance Converter"); fromUnit = SelectUnit(" Please select the from distance unit : "); toUnit = SelectUnit(" Please select the to distance unit : "); Console.WriteLine($"\n Converting {fromUnit} to {toUnit}"); fromDistance = InputDistance($" Enter the number of {fromUnit} : "); CalculateDistance(); OutputDistance(); }
/// <summary> /// Run Distance Converter App /// </summary> public void ConvertDistance() { // Distance Converter is output as heading ConsoleHelper.OutputHeading("Distance Converter"); // This looks for and gets the Unit GetUnit(); // Repeater checks if the ToUnit and FromUnit are the same. Repeater(); Console.WriteLine($"\n Converting {FromUnit} to {ToUnit}"); // Looks for an input to put into FromDistance to // convert the 2 different measurements FromDistance = (double)(UnitEnum)ConsoleHelper.InputNumber($"Please enter the" + $" number of {FromUnit} "); // Calculates the distance from the input recieved CalculateDistance(); // Outputs result OutputDistance(); }
public static void Main() { Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("BNU CO453 Applications Programming 2020-2021!"); Console.WriteLine(" Vincent Assolutissimamente 21905331"); string[] choices = { "Distance Converter", "BMI Calculator", "Student Grades", "Social Network", "RPG Game", "RockScissors", "Quit" }; bool finished = false; do { Console.WriteLine(); Console.Beep(); Console.WriteLine("What would you like to do next?"); Console.WriteLine(""); switch (ConsoleHelper.SelectChoice(choices)) { case 1: { DistanceConverter converter = new DistanceConverter(); ConsoleHelper.OutputHeading("Distance Converter"); converter.Convert(); break; } case 2: { BMICalculator bmi = new BMICalculator(); ConsoleHelper.OutputHeading("BMI Calculator"); bmi.CalculateBMI(); break; } case 3: { StudentGrades studentGrades = new StudentGrades(); ConsoleHelper.OutputHeading("Student Grades"); studentGrades.Main(); break; } case 4: { NetworkApp app04 = new NetworkApp(); app04.DisplayMenu(); break; } case 5: //RPG Game break; case 6: GameImager Imager = new GameImager(); Imager.Menu(); break; case 7: Console.WriteLine("Thank you and Goodbye!"); finished = true; break; } } while (!finished); }