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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

**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 ========================================================.

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
=¿(Tf- 32) and Tf=Tc+32
Tc
Please be careful about the integer division operator in C++ when you convert the above formula into C++
expressions. Please note that the C++ integer expression ( 5 /9 ) returns a value of 0, not 0.5556. The C++
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.
Transcribed Image Text: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 =¿(Tf- 32) and Tf=Tc+32 Tc Please be careful about the integer division operator in C++ when you convert the above formula into C++ expressions. Please note that the C++ integer expression ( 5 /9 ) returns a value of 0, not 0.5556. The C++ 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.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Knowledge Booster
File Input and Output Operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education