Write a program that creates three tables of temperatures in Celsius, Fahrenheit and Kelvin. The program will prompt the user to enter the starting temperature, the ending temperature and the increment between values all in Celsius for each test case. The program will then convert Celsius to Fahrenheit AND Kelvin creating a table of temperatures. Your program will generate three tables - one for each type of loop. TEST CASE LOOP TYPE START TEMP (C) END TEMP (C) INCREMENT (C) ONE While Loop 10 50 5 TWO Do While Loop 25 250 25 THREE For Loop 0 100 10 Fahrenheit = 9.0/5.0 * Celsius + 32.0 Kelvin = Celsius + 273.15 Here is an example of the dialog between the program and user: Prompt: Enter a starting temperature in degrees Celsius. User enters: 10 Prompt: Enter an ending temperature in degrees Celsius. User enters: 50 Prompt: Enter the increment between temperatures in degrees Celsius. User enters: 5 Example output from the third test case. FOR LOOP Celsius Fahrenheit Kelvin 0.00 32.00 273.15 10.00 50.00 283.15 20.00 68.00 293.15 30.00 86.00 303.15 40.00 104.00 313.15 50.00 122.00 323.15 60.00 140.00 333.15 70.00 158.00 343.15 80.00 176.00 353.15 90.00 194.00 363.15 100.00 212.00 373.15
Types of Loop
Loops are the elements of programming in which a part of code is repeated a particular number of times. Loop executes the series of statements many times till the conditional statement becomes false.
Loops
Any task which is repeated more than one time is called a loop. Basically, loops can be divided into three types as while, do-while and for loop. There are so many programming languages like C, C++, JAVA, PYTHON, and many more where looping statements can be used for repetitive execution.
While Loop
Loop is a feature in the programming language. It helps us to execute a set of instructions regularly. The block of code executes until some conditions provided within that Loop are true.
This program is intended to give you practice with the three loop structures in C++. You should already know how these loops are structured and how they work. If you need to review the textbook sections are given below.
- While Loop (See chapter 6 section 3)
- Do - While Loop (See chapter 7 section 2)
- For Loop (See chapter 7 section 3)
Write a program that creates three tables of temperatures in Celsius, Fahrenheit and Kelvin. The program will prompt the user to enter the starting temperature, the ending temperature and the increment between values all in Celsius for each test case. The program will then convert Celsius to Fahrenheit AND Kelvin creating a table of temperatures. Your program will generate three tables - one for each type of loop.
TEST CASE | LOOP TYPE | START TEMP (C) | END TEMP (C) | INCREMENT (C) |
ONE | While Loop | 10 | 50 | 5 |
TWO | Do While Loop | 25 | 250 | 25 |
THREE | For Loop | 0 | 100 | 10 |
Fahrenheit = 9.0/5.0 * Celsius + 32.0
Kelvin = Celsius + 273.15
Here is an example of the dialog between the program and user:
Prompt: Enter a starting temperature in degrees Celsius.
User enters: 10
Prompt: Enter an ending temperature in degrees Celsius.
User enters: 50
Prompt: Enter the increment between temperatures in degrees Celsius.
User enters: 5
Example output from the third test case.
FOR LOOP
Celsius Fahrenheit Kelvin
0.00 32.00 273.15
10.00 50.00 283.15
20.00 68.00 293.15
30.00 86.00 303.15
40.00 104.00 313.15
50.00 122.00 323.15
60.00 140.00 333.15
70.00 158.00 343.15
80.00 176.00 353.15
90.00 194.00 363.15
100.00 212.00 373.15
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images