| | |
Problem with while loop... probably common
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
Hi all...
Was wondering if someone could lend a hand - or an eye. I've been trying for hours and was hoping that someone could give me an outside look. I won't beat around the bush, yes this is from a homework assignment, but the assignment is much more than just the loop, and might I add again that I have been working on it for the past couple of days. Here is the loop,
I'm trying to get the loop to stop at the end of the file (inData), but the problem that I run into is that the last temperature(value) in the file gets printed twice.
Thanks Much,
Nate
Was wondering if someone could lend a hand - or an eye. I've been trying for hours and was hoping that someone could give me an outside look. I won't beat around the bush, yes this is from a homework assignment, but the assignment is much more than just the loop, and might I add again that I have been working on it for the past couple of days. Here is the loop,
C++ Syntax (Toggle Plain Text)
while(inData) { inData>>temp1; if(temp1>120 || temp1<-30) { cout<<"Error: Temperature must be between -30 & 120 degrees." <<endl <<endl; return 1; } else if (temp1>=120) cout<<setw(72) <<"*" <<endl; else if (temp1>=110) cout<<setw(68) <<"*" <<endl; else if (temp1>=100) cout<<setw(64) <<"*" <<endl; else if (temp1>=90) cout<<setw(60) <<"*" <<endl; else if (temp1>=80) cout<<setw(56) <<"*" <<endl; else if (temp1>=70) cout<<setw(52) <<"*" <<endl; else if (temp1>=60) cout<<setw(48) <<"*" <<endl; else if (temp1>=50) cout<<setw(44) <<"*" <<endl; else if (temp1>=40) cout<<setw(40) <<"*" <<endl; else if (temp1>=30) cout<<setw(36) <<"*" <<endl; else if (temp1>=20) cout<<setw(32) <<"*" <<endl; else if (temp1>=10) cout<<setw(28) <<"*" <<endl; else if (temp1>=0) cout<<setw(24) <<"*" <<endl; else if (temp1>=-10) cout<<setw(20) <<"*" <<endl; else if (temp1>=-20) cout<<setw(16) <<"*" <<endl; else if (temp1>=-30) cout<<setw(12) <<"*" <<endl; }
Thanks Much,
Nate
Behind every great gymnast - is a mentally unstable coach.
![]() |
Similar Threads
- Problem with do-while loop (C++)
- For loop problem (Java)
- problem with do...while loop (C++)
- problem with loop (C++)
- a for loop problem (Java)
- problem with MATLAB loop (Legacy and Other Languages)
Other Threads in the C++ Forum
- Previous Thread: i need a project
- Next Thread: how can i find out some char from string?
| Thread Tools | Search this Thread |
api array based beginner bitmap c++ c/c++ calculator char class classes code coding compile compiler console conversion count database delete deploy desktop developer directshow dll download dynamic email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory multiple news node number output parameter pointer problem program programming project python random read recursion recursive return sorting string strings struct temperature template templates test text text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets





