Program promts for and reads an interger value and prints a warning message based on value:
<0 "Error in input"
>=0, <50 'Pressure in the normal range"
>=50, <100 'Pressure on high side"
>=100 "Evacuate"
*************************************
here is my program so far
#include <iostream>
#include <fstream>
using namespace std;
int main ()
{
int pressure;
ifstream data;
bool notNegative = true;
data.open("Shell3.D1");
while(notNegative)
{
data >> pressure;
if (pressure <0)
{
notNegative=false;
cout<< "Error in output"<<endl;
}
if (pressure >= 0 && pressure < 50)
cout << "Pressure in the normal range" <<endl;
if(pressure >=50 && pressure < 100)
cout << "Pressure on High Side"<<endl;
if (pressure >=100)
cout << "Evacuate plant!!!"<<endl;
}
return 0;
}
******************************************
shell3.d1 file looks like this:
-3
6
49
50
51
99
1
55
100
*****************************************
now when I execute its reads first number and its stops (says Error lalal ( -3) :angry: :angry:
what I have to do to force this program to check all number and not only 1st one and display on the screen. Please explain I need to know this. Thank u
Question
webeagle12
ok Here is the program:
Program promts for and reads an interger value and prints a warning message based on value:
<0 "Error in input"
>=0, <50 'Pressure in the normal range"
>=50, <100 'Pressure on high side"
>=100 "Evacuate"
*************************************
here is my program so far
#include <iostream>
#include <fstream>
using namespace std;
int main ()
{
int pressure;
ifstream data;
bool notNegative = true;
data.open("Shell3.D1");
while(notNegative)
{
data >> pressure;
if (pressure <0)
{
notNegative=false;
cout<< "Error in output"<<endl;
}
if (pressure >= 0 && pressure < 50)
cout << "Pressure in the normal range" <<endl;
if(pressure >=50 && pressure < 100)
cout << "Pressure on High Side"<<endl;
if (pressure >=100)
cout << "Evacuate plant!!!"<<endl;
}
return 0;
}
******************************************
shell3.d1 file looks like this:
-3
6
49
50
51
99
1
55
100
*****************************************
now when I execute its reads first number and its stops (says Error lalal ( -3) :angry: :angry:
what I have to do to force this program to check all number and not only 1st one and display on the screen. Please explain I need to know this. Thank u
Link to comment
Share on other sites
2 answers to this question
Recommended Posts