Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

Temperature Converter/help please

+1 vote
asked Oct 17, 2018 by Christina1 (310 points)

Modify the previous version of this program so that it uses a loop to display a range of temperature conversions for either Fahrenheit to Celsius or Celsius to Fahrenheit.

Note: You can start with the code from the previous version, then modify it slightly after it prompts the user for the direction to convert. It will then ask the user for a starting temperature and ending temperature. Assuming they entered the lower number first (if not, tell them and end the program), loop through the range provided, incrementing by 1 for each iteration of the loop, and generate the appropriate table.

The output should look like this:
Temperature Conversion Table
Enter c (or C) to convert Fahrenheit to Celsius
   or f (or F) to convert Celsius to Fahrenheit: F
Enter the starting temperature: 30
Enter the ending temperature: 42

Celsius  Fahrenheit
    30        86.0
    31        87.8
    32        89.6
    33        91.4
    34        93.2
    35        95.0
    36        96.8
    37        98.6
    38       100.4
    39       102.2
    40       104.0
    41       105.8
    42       107.6

Running the program again:
Temperature Conversion Table
Enter c (or C) to convert Fahrenheit to Celsius
   or f (or F) to convert Celsius to Fahrenheit: c
Enter the starting temperature: -4
Enter the ending temperature: 4

Fahrenheit  Celsius
    -4       -20.0
    -3       -19.4
    -2       -18.9
    -1       -18.3
     0       -17.8
     1       -17.2
     2       -16.7
     3       -16.1
     4       -15.6

2 Answers

0 votes
answered Oct 20, 2018 by anonymous
0 votes
answered Oct 20, 2018 by anonymous
use switch statement
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...