i need to fix this error #include<iostream> #include<iomanip> using namespace st
ID: 3703344 • Letter: I
Question
i need to fix this error
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
//variables
double temp1,temp2,inc,cel;
int i=1;
while(i==1)
{
i=0;
cin>>temp1>>temp2>>inc;
if(temp2<temp1||inc<=0)
{
i=1;
cout<<"Starting temperature must be <= ending temperature and increment must be > 0.0 ";
}
}
cout<<endl;
cout<<setw(15)<<"Fahrenheit"<<setw(15)<<"Celsius";
while(temp1<=temp2)
{
cel=(temp1-32)/1.8;
cout<<endl;
//output temperature
cout<<fixed<<setprecision(3)<<setw(15)<<temp1<<setw(15)<<cel;
temp1+=inc;
}
}
zy 5.16. Lab Lesson 3 (PartCI Need To Fix This Lorx ? secure https://learn.zybooks.com/zybook/UTDALLASCS 11 36Spring2018LabB/Chapter/5/section/16 . ::: Apps D Paymenis O barn P Probability ?? ? Sighlbox: Sirn liy Wal hil wi Mel Y Pak Idr-Relig unP D Paki lar' RELIGION D Paki lan Men nd zyBooks Mylbrary:-CSI 136 hme-S.16: Lab Lessore Pert 2012} ez,000ks catalog @repro ? Hijnsen Output is nearly correct, but whitespace differs. See highlights be plal charactar logend 0 305 30 40 - 20 20 5 Input 35.000 .667 Expected output 1.667 40-000 0/5 Output is nearly correct; but whitespace differs. See highlights below Spl charactar logond Input 102.5 110.3 Your output 40.333 100 s0 105-500 Expected output 35.056 Type here to search 1016 PM 4/8/2018Explanation / Answer
try this code..it will work..
================================================================
Program:
===============================================================
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
//variables
double temp1,temp2,inc,cel;
do
{
cin>>temp1>>temp2>>inc;
if(temp2<temp1||inc<=0)
{
cout<<"Starting temperature must be <= ending temperature and increment must be > 0.0 ";
}
}while(temp2<temp1 || inc<=0);
cout<<setw(15)<<"Fahrenheit"<<setw(15)<<"Celsius";
while(temp1<=temp2)
{
cel=(temp1-32)/1.8;
cout<<endl;
//output temperature
cout<<fixed<<setprecision(3)<<setw(15)<<temp1<<setw(15)<<cel;
temp1+=inc;
}
cout<<endl;
}
================================================================
Input:
40 30 5
30 40 0
30 40 5
===============================================================
Sample Output:
===============================================================
Kindly Check and Verify Thanks..!!!
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.