Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a C++ program that prompts the user to enter a value that represents a tem

ID: 2085892 • Letter: W

Question

Write a C++ program that prompts the user to enter a value that represents a temperature reading in centigrade. The program will convert the input to the equivalent Fahrenheit and display the conversion on the monitor. For example if the user enter the temperature reading 0 the program should display the equivalent Fahrenheit temperature = 32 degrees. T_(degree F) = T_(degree C) times 9/5 + 32 or T_(degree F) = T_(degree C) times 1.8 + 32 Modify the program you wrote in Exercise 1 above to allow the user the option to convert from Fahrenheit to centigrade or from Centigrade to Fahrenheit First step: The program prompts the user to enter the type of conversion he/she wants to make. Example: enter 1 if you want to convert from Fahrenheit to centigrade, enter 2 to convert from centigrade to Fahrenheit Second step: The program then performs the selected conversion and display the output to the monitor Third step: The program should decide if the temperature entered is hot, moderate or cold based on the following ranges: 1. temperature

Explanation / Answer

1) The code for Fahrenheit conversion is:

#include <iostream>
using namespace std;
int main() {

   float fahrenheit,celsius;
   cout << "Enter the temperature in Celsius: ";
   cin >> celsius;
   fahrenheit = (celsius * 9.0)/5.0 + 32;
   cout << "Temperature in Fahrenheit= " << fahrenheit;
   return 0;
}

2) The second part of the question where the user enters what conversion the user wants:
For this case we have assumed that 50F belongs to moderate temperature and 75F belongs to Hot Temperature as nothing was mentioned in the question:

#include <iostream>
using namespace std;
int main() {
int x;
float fahrenheit,celsius;
cout << "Enter 1 if you want to convert from Fahrenheit to centigrate and enter 2 to convert from centigrade to Fahrenheit.";
cin >> x;
if(x == 1) {
cout << "Enter the temperature in Fahrenheit: ";
cin >> fahrenheit;
   celsius = (fahrenheit - 32)* 5.0/9.0 ;
   cout << "Temperature in Celsius= " << celsius << " ";
   }
else if (x == 2) {
cout << "Enter the temperature in Celsius: ";
   cin >> celsius;
   fahrenheit = (celsius * 9.0)/5.0 + 32;
   cout << "Temperature in Fahrenheit= " << fahrenheit << " ";
   }
if(fahrenheit < 50)
cout << "Temperature is Cold ";
   else if (fahrenheit >= 50 & fahrenheit < 75)
   cout << "Temperature is Moderate ";
else
    cout << "Temperature is Hot ";
return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote