PJ 3 – Temperature Conversion Game Please write a C++ program that will convert a temperature from Fahrenheit to Celsius, and then convert a temperature from Celsius to Fahrenheit. If the user enters -999 for a temperature, your program must stop and present a thank-you message. The C++ statements to exit the while (true) loop when tf or tc is -999 are as follows: if (tf == -999.0) break; // exit the while loop since temperature Fahrenheit is -999 if (tc == -999.0) break; // exit the while loop since temperature Celsius is -999 The two conversion formulas are as follows: 9. Т. т-32) аnd T3т+32 Tf = 3Tc c +32 Please be careful about the integer division operator in C++ when you convert the above formula into C++ Please note that the C++ integer expression ( 5/9) ret a value of 0, not 0.5556. The C++ expres integer expression ( 9 / 5 ) returns 1, not 1.8. However, the C++ floating-point expression ( 5. / 9. ) returns 0.5556, which is correct. Therefore, you must use floating-point expressions for the conversion formulas.
**THIS IS MY CODE I HAVE SO FAR. ONLY NEED HELP WITH AREAS WITH //**
#include <iostream>// Access input output stream: cin cout
#include <iomanip> // Access manipulators: setw(20) setprecision(2)
using namespace std; // Access cout, cin, endl without using std:: as prefix
int main() // int main( ) function must return an integer to the caller.
{
int n = 1; // line number for each separation line for readability
double tc, tf; // temperature C, temperature F, double to avoid conversion warning
cout << "Welcome to the Temperature Conversion Tool of Jali!" << endl;
while (true) // an infinite loop to be stopped by user's input of -999
{ //while loop
cout << n++ << "=============================================================" << endl;
cout << "Please enter a temperature in Fahrenheit: (-999 to quit) " ;
cin >> tf; // get input for tf
// C++ statements to convert tf to tc & print them nicely
cout << "Please enter a temperature in Celsius: (-999 to quit) " ;
cin >> tc; // get input for tc
// C++ statements to convert tc to tf & print them nicely
} // end of while loop
cout << n++ << "=====================================================" << endl;
cout<<"Thank you for using the Temperature Conversion Tool of Jali!"<<endl;
cout << n++ << "=====================================================" << endl;
int quit; // define integer variable quit
cout << "To really quit this game, please enter a number: " << endl;
cin >> quit ; // get input for quit
return 0; // return zero to indicate the successful completion of this program.
} // end main() function ========================================================.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 3 images