PJ 4 – Temperature Table Please write a C++ program that will get 7 temperatures in Fahrenheit from the user, convert them to 7 temperatures in Celsius respectively, and then print a table of 7 temperatures from Fahrenheit to Celsius. All the temperatures in the output must show only one decimal digit after the decimal point. The temperature conversion formulas are as follows: 9. T =,(T;- 32) and T;=3T.+32 %3D
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
cout << "Welcome to the Temperature Tool of Layla !\n" << endl << endl;
double tf1, tf2, tf3, tf4, tf5, tf6, tf7;
double tc1, tc2, tc3, tc4, tc5, tc6, tc7;
cout << "Please enter 7 temperatures in Fahrenheit: " ;
cin >> tf1 >> tf2 >> tf3 >> tf4 >> tf5 >> tf6 >> tf7 ;
tc1=5*(tf1-32)/9;
tc2=5*(tf2-32)/9;
tc3=5*(tf3-32)/9;
tc4=5*(tf4-32)/9;
tc5=5*(tf5-32)/9;
tc6=5*(tf6-32)/9;
tc7=5*(tf7-32)/9;
cout <<"degree F" <<setw(35) << "degree C" <<endl;
cout <<fixed<< setprecision(1)<<tf1 <<setw(35)<<fixed << setprecision(1)<< tc1 <<endl;
cout <<fixed<< setprecision(1)<<tf2 <<setw(35)<<fixed << setprecision(1)<< tc2 <<endl;
cout <<fixed<< setprecision(1)<<tf3 <<setw(35)<<fixed << setprecision(1)<< tc3 <<endl;
cout <<fixed<< setprecision(1)<<tf4 <<setw(35)<<fixed << setprecision(1)<< tc4 <<endl;
cout <<fixed<< setprecision(1)<<tf5 <<setw(35)<<fixed << setprecision(1)<< tc5 <<endl;
cout <<fixed<< setprecision(1)<<tf6 <<setw(35)<<fixed << setprecision(1)<< tc6 <<endl;
cout <<fixed<< setprecision(1)<<tf7 <<setw(35)<<fixed << setprecision(1)<< tc7 <<endl;
cout << endl << "Thank you for using the Temperature Tool of Layla!\n" << endl;
int quit;
cout << "To really quit this game, please enter a number: " << endl;
cin >> quit;
return 0;
}
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images