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 C++ program, using while statement, to convert meters to feet. The program should request...
Write a C++ program, using while statement, to convert meters to feet. The program should request the starting meter value, the ending meter value, and the increment between metric values. The display should have appropriate headings and list the meters and the corresponding feet value. If the number of iterations is greater than 20, have your program substitute a default increment of (ending value - starting value) / 19. Use the relationship that 1 meter = 3.28 feet.
In C++ write a program for a multiplication table It must Prompt the user for two...
In C++ write a program for a multiplication table It must Prompt the user for two integers between 1 and 20 (inclusive) • also must Calculates and displays the multiplication table in a well-formatted output The table must include a label for each row and column The program must follow the requirements: • Validates user input, displaying an error message and prompting to user to enter another integer if the input is invalid, and repeating it as many times as...
in c++ Write a C++ program that asks the user to enter an integer number and...
in c++ Write a C++ program that asks the user to enter an integer number and prints it back "vertically" to the screen. Use recursion in your solution. As an example of how the program will work: Please enter an integer: 12345 The integer you entered will print vertically as: 1 2 3 4 5
in c++ Write a program that asks the user for the speed of a vehicle (in...
in c++ Write a program that asks the user for the speed of a vehicle (in miles per hour) and how many hours it has traveled. It should use a loop to display the total distance traveled. The speed traveled should be limited by the fastest speed achieved by a car thus far. Values should not be negative.•Ex: if hours = 3 and speed = 40, then the program should display•Hour 1: Distance Traveled: 40 miles•Hour 2: Distance Traveled: 80...
Question: Squares. Write a program class named SquareDisplay that asks the user for a positive integer...
Question: Squares. Write a program class named SquareDisplay that asks the user for a positive integer no greater than 15. The program should then display a square on the screen using the character ‘X’. The number entered by the user will be the length of each side of the square. For example, if the user enters 5, the program should display the following:       XXXXX       XXXXX       XXXXX       XXXXX       XXXXX INPUT and PROMPTS. The program prompts for an integer as follows: "Enter...
This program is in C++: Write a program to allow the user to: 1. Create two...
This program is in C++: Write a program to allow the user to: 1. Create two classes. Employee and Departments. The Department class will have: DepartmentID, Departmentname, DepartmentHeadName. The Employee class will have employeeID, emploeename, employeesalary, employeeage, employeeDepartmentID. Both of the above classes should have appropriate constructors, accessor methods. 2. Create two arrays . One for Employee with the size 5 and another one for Department with the size 3. Your program should display a menu for the user to...
1. Write a complete program in C++ that does the following: [2] asks a user to...
1. Write a complete program in C++ that does the following: [2] asks a user to enter two integer numbers (display a warning message that the second number should be different from zero) [3] reads the two numbers from the keyboard; [4] displays the product, the sum, the quotient and the remainder of integer division of the first one by the second one. [3] displays the result of floating-point division. Make sure to follow programming style guidelines.
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT