I am creating a shipping cost program that compares the package weight to 2 values followed by the output of the shipping cost. If the package weight is larger than the compared 2 values, the program compares the package weight again to another 2 values. This comparison happens up to a total of 4 times...when I get to the last comparison I start by typing:
else (comparison of package weight to 2 values)
cout << "The Shipping Cost is whatever";
In VS 2010, it underlines the cout in red, and it reads that ; must come before it. In my programming book it does not mention this. Why must I put ; before cout in order for it to compile the code? This is the first time I've had to place anything right before cout.
If there are only four conditions that are possible, you don't need the (condition4) after the last else. Or, you add the if after that last else, and add a
1 2
else
cout << "Sorry, do not understand that input." << endl;
The (condition4) is not legal C/C++. The whole point of an else block is that it runs in all circumstances where none of the other conditions were met.