206k views
0 votes
You need to display output for all of the values between the starting and ending values. First two values are temperatures in Fahrenheit. You need to display all of the values from the first temperature to the last temperature. You increment from one temperature to the next by the increment value (the third value you read in). You need to convert these temperatures to Celsius and Kelvin. You need to output the temperatures as Fahrenheit, Celsius, and Kelvin. The numbers should be 18 characters wide with 4 digits of precision and need to be in fixed format. Do not use tab characters (\t) to output the values.

1 Answer

4 votes

Answer:

Check the explanation

Step-by-step explanation:

#include<iostream>

#include<iomanip>

using namespace std;

int main()

{

double temp1,temp3,inc,cel;

int i=1;

while(i==1)

{

i=0;

cin>>temp1>>temp3>>inc;

if(temp3<temp1||inc<=0)

{

i=1;

cout<<"Starting temperature must be <= ending temperature and increment must be >0.0\\";

}

}

cout<<endl;

cout<<setw(18)<<"Fahrenheit"<<setw(18)<<"Celsius";

while(temp1<=temp3)

{

cel=(temp1-32)/1.8;

cout<<endl;

cout<<fixed<<setprecision(4)<<setw(18)<<temp1<<setw(18)<<cel;

temp1+=inc;

}

}

User Xneg
by
6.2k points