Question: Please use code provided to answer the following question. Font PROGRAMMING PROBLEM: [4+15+4*4 points) Using the four-step development method, write a universal temperature converter C++




Font PROGRAMMING PROBLEM: [4+15+4*4 points) Using the four-step development method, write a universal temperature converter C++ program that accepts a temperature in Celsius, Fahrenheit, or Kelvin and converts to the desired unit. If the user enters a letter following the temperature number as f, the program is to treat the number entered as a temperature in degrees Fahrenheit, and so on for the other units of temperature. As specified by the user, convert the temperature number to the equivalent degrees Celsius, Fahrenheit, or Kelvin, and display a suitable message. If the letter is neither f nor c nork, the program is to display a message that the data entered is incorrect and terminate. Use an if-else if-else chain in your program and make use of these conversion formulas: 19.0 Fahrenheit = X Celsius + 32.0 Kelvin = Celsius + 273.15 Display the results with 2 decimal places of accuracy Develop the program on MS Visual Studio, debug, and run with different test cases, I SOLUTION: Step 1: Analyze the problem There are three user inputs: temperature, its type (Fahrenheit or Celsius or Kelvin), and conversion to Celsius or Fahrenheit or Kelvin The temperature is a real number and as such needs to be defined as double deg: The type of the temperature needs to be entered as a character 'e','f', or 'k' by the user. Thus, it can be declared as char letter; The desired conversion to 'd', 'e', or 'k can be represented by char conv; The output will be the converted temperature to be displayed with its appropriate type. We will reuse the "temp" variable defined for input as the output variable. Step 2: Find a Solution Prompt user for three inputs and save them into variables deg, letter, and conv. The following pseudo-code will be implemented using if-else if-else chain. If the temperature (deg) is specified in Kelvin (letter), the conversion to Fahrenheit (conv) is done by deg (9.0/5.0) (deg 273.15) + 32.0; the conversion to Celsius is done by deg - deg - 273.15; If the temperature is specified in Celsius, the conversion to Fahrenheit is done by deg - (9.0/5.0) deg 32.0; the conversion to Kelvin is done by deg - deg + 273.15; If the temperature is specified in Fahrenheit, the conversion to Celsius is done by deg (5.0/9.0) (deg 32.0); the conversion to Kelvin is done by (5.0/9.0) (deg 32.0) + 273.15; If the temperature type is specified to be anything other than 'c' or 'f' or 'K', display an error message. deg We will set the formatting of the display of converted temperature to have two digits of accuracy after the decimal point cout library Calculate the results for the following test inputs (to be used as test cases) (a) 98.4 ftoc (b) 273.15 k tof (write the value) (write the value) cout library. Calculate the results for the following test inputs (to be used as test cases): (a) 98.4 ftoc (b) 273.15 k tof (c) -40 c to f (d) -459.67 ftok IL1011 (write the value) (write the value) (write the value) (write the value) #include
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
