I keep receiving an undeclared identifier error for \'meter\'. can anyone help?
ID: 669882 • Letter: I
Question
I keep receiving an undeclared identifier error for 'meter'. can anyone help?
#include<iostream>
#include<string>
using namespace std;
int main()
{
string str;
cout<<"enter color of status light";
cin>>str;
cout<<endl<<str;
if(str=="green")
cout<<"kindly restart the procedure."<<endl;
else if (str=="amber")
cout<<endl<<"check fuel line service routine";
else if (str=="red")
string meter;
cout<<endl<<"shut off all input lines. check meter number 3.";
cin>>meter;
if(meter>=50)
string str1;
cout<<endl<<"measure flow velocity at inlet 2-B";
cin>>str1;
if(str1=="high" || str1="low")
cout<<endl<<"refer unit for factory service";
if(str1=="normal")
cout<<endl<<"refer to inlet service manual.";
else
string str2;
cout<<endl<<"check main line for test pressure";
cin>>str2;
if(str2=="high" || str2="low")
cout<<endl<<"refer to main line manual";
if(str2="normal")
cout<<endl<<"refer to motor service manual.";
system("pause");
return 0;
}
Explanation / Answer
Program is corrected/modified and tested. Please find below, the modified program:
#include<iostream>
#include<string>
using namespace std;
int main()
{
string str;
cout<<"enter color of status light: ";
cin>>str;
cout<<str<<endl;
if(str=="green")
cout<<"kindly restart the procedure."<<endl;
else if (str=="amber")
cout<<"check fuel line service routine"<<endl;
else if (str=="red")
{
//string meter;
int meter;
cout<<"shut off all input lines. check meter number 3.: ";
cin>>meter;
cout<<meter<<endl;
if (meter >= 50)
{
string str1;
cout<<"measure flow velocity at inlet 2-B: ";
cin>>str1;
cout<<str1<<endl;
if (str1=="high" || str1=="low")
cout<<"refer unit for factory service"<<endl;
else if (str1=="normal")
cout<<"refer to inlet service manual."<<endl;
}
else{
string str2;
cout<<"check main line for test pressure: ";
cin>>str2;
cout<<str2<<endl;
if (str2=="high" || str2=="low")
cout<<"refer to main line manual"<<endl;
else if (str2=="normal")
cout<<"refer to motor service manual."<<endl;
}
}
//system("pause");
return 0;
}