Colour Theme Font Size Options
 
 
 
Exercise 2

Event Loop Nesting Exercise:

Create a C++ program ex2_converth.cpp with the following code in the Visual Studio project or copy the following code into another IDE:


Instructions

  • Compile and run the program. It should seem familiar - this is one possible solution to the Fahrenheit-Celsius program you saw earlier this semester.

  • Add a do-while loop to ask the user to enter data until they say they are done.
    Follow the ADD CODE: instructions in the program. They will guide you through the following tasks:
    • Start the loop right after the menu is printed.
    • End the loop after the results are printed and before the final return statement.
    • Before the loop ends, and after results are printed, ask the user if they want to convert another temperature, eg:
      Do you want to convert another temperature? (y/n)
    • The loop should repeat while their answer is 'y'.

  • Add a while loop nested inside the do-while loop. It will replace the if-else that makes sure that a valid letter is entered before calculating. The while loop should repeat until a valid letter is entered.
    Use your judgement to do it correctly.

When you are done:

  • Take a screenshot that shows at least two conversions, includes one sample bad letter, and ends the outer loop properly.
  • For this exercise, you will have: ex2_converth.cpp.
  • Complete all the exercises in this option and upload the .cpp files and screenshots to URCourses.