Question

C++ Fahrenheit to Celsius Tables Write a program that first asks the user which Temperature scale...

C++ Fahrenheit to Celsius Tables

Write a program that first asks the user which Temperature scale conversion he/she would like to perform:

1. Convert F to C

2. Convert C to F

3. Quit What is your choice?

Then it asks the user for input for three real number variables: start_temp, end_temp, temp_incr. It will then produce a two column Fahrenheit to Celsius table or a two column Celsius to Fahrenheit table, depending on the choice. For choice 1, the first column should be labeled Fahrenheit and the first value the Fahrenheit column is start_temp. The second column should be labeled Celsius, and its value is calculated from the values in the Fahrenheit column using the formula C = (5.0/9.0)*(F – 32.0). For choice 2, the table will show the Celsius column first, Fahrenheit column second, and use the formula F = 9.0/5.0 * C + 32.0 The values for the temps in the first column will be incremented by temp_incr, and end when the table value would exceed the end_temp value. Display all values with 2 decimal of accuracy, justified and aligned.

Requirements:

1)    A detailed algorithm
2)    Verify all numeric data are acceptable and not character
3)    Follow all good programming practices such as descriptive variable names, constants names, proper indentation,...
4)    Verify input for correct range and type ( not character)
5)    Output should be the same as the sample shown below, I used 30 ‘–‘ for the underlining of heading.

Sample Output

Output Sample: 

Choose a conversion type: 
        1. Convert F to C
        2. Convert C to F
        3. Quit

            What is your choice?  1

Enter starting value:         29 
Enter ending value:        32
Enter increment value:    0.5

Fahrenheit           Celsius 
29.00               -1.67
29.50               -1.39
30.00               -1.11
30.50               -0.83
31.00               -0.56
31.50               -0.28
32.00                0.00
Choose a conversion type:
             1. Convert F to C
             2. Convert C to F
             3. Quit

              What is your choice?  4

Invalid choice. Try again.
Choose a conversion type:
             1. Convert F to C
             2. Convert C to F
             3. Quit

              What is your choice?  2

Enter starting value:        35
Enter ending value:            32
Enter increment value:    -1

Celsius         Fahrenheit   
35.00        95.00
34.00        93.20
33.00        91.40
32.00        89.60
Choose a conversion type:
             1. Convert F to C
             2. Convert C to F
             3. Quit

              What is your choice?  2

Enter starting value (integer number):     35
Enter ending value (integer number):     32
Enter increment value (real number):    1

Invalid range. Try again.
Choose a conversion type:
               1. Convert F to C
               2. Convert C to F
               3. Quit

               What is your choice?  3

Thank you for your using my program. Program terminated.

Homework Answers

Answer #1

Program for Temperature Conversion :

1. From Celsius to Fahrenheit

2. From Fahrenheit to Celsius

3. To Exit

#include<iostream>
using namespace std;
int main()
{
  int a;
  cout<<"1. For Celsius To Fahrenheit. \n";
  cout<<"2. For Fahrenheit To Celsius. \n";
  cout<<"3. For Exit\n\n";
  cout<<"Enter Your Choice \n ";
  cin>>a;
  switch(a)
   { 
    double cel,feh;
    case 1: cout<<"Enter The Temperature In Celsius\n";
      cin>>cel;
      feh=(cel*9/5)+32;
      cout<<"\nTemperature In Fahrenheit Is = "<<feh ;
    break;
   
   case 2: cout<<"Enter The Temperature In Fahrenheit\n";
      cin>>feh;
      cel=(feh-32)*5/9;
      cout<<"\nTemperature In Celsius Is = "<<cel ;
    break;
      
   case 3:exit(0);
   
   default:cout<<"\nEnter The Right Choice \n";
    break;     
   }
}
 
Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
C++ Program: Prompt the user to enter a Fahrenheit degree then using the following formula to...
C++ Program: Prompt the user to enter a Fahrenheit degree then using the following formula to convert it to Celsius degree. Don't accept any value less than -60 and more than 200. C = (5/9)*(F – 32)
3. The following is the formula to convert a Celsius degree to Fahrenheit degree: Fahrenheit =...
3. The following is the formula to convert a Celsius degree to Fahrenheit degree: Fahrenheit = (9/5) Celsius + 32 Write a program to prompt user to enter a Celsius degree, convert it to Fahrenheit and display Given an integer value which is the measurement of weight in ounce. Convert it to the format of: x pounds and y ounces. For example, if the given number is 100 ounces, it will be represented as 6 pounds and 4 ounces after...
In c++ format please Most people know that the average human body temperature is 98.6 Fahrenheit...
In c++ format please Most people know that the average human body temperature is 98.6 Fahrenheit (F). However, body temperatures can reach extreme levels, at which point the person will likely become unconscious (or worse). Those extremes are below 86 F and above 106 F. Write a program that asks the user for a body temperature in Fahrenheit (decimals are ok). Check if that temperature is in the danger zone (for unconsciousness) or not and produce the relevant output shown...
Write a function called celsiusToFaherenheit which takes 1 input: degrees in Celsius, and returns one output:...
Write a function called celsiusToFaherenheit which takes 1 input: degrees in Celsius, and returns one output: degrees in Fahrenheit. The formula to convert Celsius to Fahrenheit is (°C × 9/5) + 32 = °F. Write a function called printCelsiusToFaherenheit which takes no inputs and returns no outputs. This function should use celsiusToFaherenheit from part 3 as a helper function. This function should print the value of 17 degrees Celsius converted to Fahrenheit.
Objective: Write a Java program that will use a JComboBox from which the user will select...
Objective: Write a Java program that will use a JComboBox from which the user will select to convert a temperature from either Celsius to Fahrenheit, or Fahrenheit to Celsius. The user will enter a temperature in a text field from which the conversion calculation will be made. The converted temperature will be displayed in an uneditable text field with an appropriate label. Specifications Structure your file name and class name on the following pattern: The first three letters of your...
. Let F be an RV that represents the operating temperature in Fahrenheit of one instance...
. Let F be an RV that represents the operating temperature in Fahrenheit of one instance of a manufacturing process, and let F ∼ N(90, 5 2 ). Let C be an RV that represents the same process, but measured in Celsius. Fahrenheit can be converted to Celsius using C = 5 9 (F − 32). (I recommend doing these with a calculator and N(0, 1) table as practice for the exam. Then check your answers with R if you...
Create a program that the simulates a thermometer and displays its temperature using different units. 1-...
Create a program that the simulates a thermometer and displays its temperature using different units. 1- Temperature Interface (Temperature.java) This interface should declare the following two abstract methods: • getTemperature      o Returns a String o Accepts no arguments • setTemperature      o Returns void o Accepts one double argument 2- Abstract Thermometer Class (Thermometer.java) This abstract class must implement the Temperature interface and contain: • One private field (a double) named degrees • One constructor that accepts a double...
in C++, Program 4: Conversion between Bases Write a program that will convert a decimal number...
in C++, Program 4: Conversion between Bases Write a program that will convert a decimal number to binary, octal, and hexadecimal (base 2, 8, and 16). Program Requirements: Prompt the user to input an integer value in decimal (base 10) and display the value in base 2, 8 and 16. Do NOT use built-in conversion methods for the conversion. You must do your own math to compute the values. Repeat the prompt and conversion until the user enters a sentinel...
Ice Cream Program Assignment Write a program in c# that uses a function to ask the...
Ice Cream Program Assignment Write a program in c# that uses a function to ask the user to choose an ice cream flavor from a menu (see output below.) You must validate the users input for the flavor of ice cream accounting for both upper and lower-case letters. You must give them an appropriate error message and allow them to try again.   Once you have a valid flavor, your function will return the flavor back to the main() function.   ...
(Do this in C++ please and make sure no compile/run errors): I. Write a function that...
(Do this in C++ please and make sure no compile/run errors): I. Write a function that writes a series of random Fahrenheit temperatures and their correspond- ing Celsius temperatures to a tab-delimited file. Use 32 to 212 as your temperature range. From the user, obtain the following: 1. The number of temperatures to randomly generate. 2. The name of the output file. A sample run is included below (you must follow the format provided below): Please enter the name of...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT
Active Questions
  • Given a relational database that consists of the following relations: Performer (pid: integer, pname: string, years_of_experience:...
    asked 2 minutes ago
  • Using Python: Write a program which includes functions to calculate the area, perimeter and diameter of...
    asked 10 minutes ago
  • CISP 400 C++ Programming    Please note, you are required to include the following when you...
    asked 21 minutes ago
  • During lunch hour, customers arrive at a fast food drive-through window, on average, every 2.9 minutes....
    asked 21 minutes ago
  • Support the storing of additional user information: street address (string), city( string), state (string), and 10-digit...
    asked 21 minutes ago
  • The United States Census Bureau uses demographic information to set a poverty threshold that is used...
    asked 35 minutes ago
  • 1. Give a well-reasoned explanation, with sufficient data, for your choice of method for each of...
    asked 46 minutes ago
  • Explain following terms .. a. Recursive function b. Base case of recursion      IN C LANGUAGE
    asked 52 minutes ago
  • You may need to use the appropriate appendix table or technology to answer this question. A...
    asked 55 minutes ago
  • Suppose this reaction proceeds as expected to give a mixture of diastereomers. How will that affect...
    asked 56 minutes ago
  • For each of the following, write a single statement that performs the indicated task. Assume that...
    asked 58 minutes ago
  • Write a Python program that computes the income tax for an individual. The program should ask...
    asked 1 hour ago