ok.. first thing.. please use [code][/code] tags around the code. This formats it and makes it easier for us to read.
Second, on your if, else if, and else statements, if there is mroe than one command (as indicated by more than one semi-colon ';') then you need to put parenthasis around the block of code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
if (serviceCode == 'r' || serviceCode == 'R') // notice i compare twice
{
cout <<"Please enter the number of minutes you have used : " << endl;
cin >> noOfMins_daily;
}
elseif (serviceCode == 'p' || serviceCode == 'P')
{
cout << "Please enter the number of minutes you have used during the day : " << endl;
cout << "Please enter the number of minutes you have used during the night : " << endl;
}
else
{
cout << "Input error!!" << endl;
cin.clear();
cin.ignore(200,'\n');
}
return 0;
You can only skip the parenthasis if you have one command, one operation, one line of code to follow the if statement.
1 2 3 4 5 6 7 8 9
If (false)
cout << "this line is part of the if statement" << endl; // this will not print
cout << "this line is not part of the if statement" << endl; // this will print
If (true)
{
cout << "this line is part of the if statement" << endl;
cout << "and so is this line." << endl;
}
Aakanaar's article about conditions being true or false will explain what exactly you have wrong... http://www.cplusplus.com/forum/articles/3483/
(Aakanar's answer has the error corrected)