By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,731 Members | 1,060 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,731 IT Pros & Developers. It's quick & easy.

Why am I recieving this error C2061: identifier 'cout' while trying to complile?

P: 2
Expand|Select|Wrap|Line Numbers
  1.  #include <iostream>
  2. #include <iomanip>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     //declare variables
  10.     string name = " ";
  11.     double saleAmount = 0.0;
  12.     double shippingCharge = 0.0;
  13.  
  14.     // ask  user for input
  15.     cout << "Plese Enter sales amount: ";
  16.     cin >> saleAmount;
  17.     cout << endl << endl;
  18.  
  19.     // calculate shipping charge
  20.     cout << "Calculating shipping charge" << endl;
  21.     if (saleAmount > 5,000.00)
  22.         (shippingCharge = 20.00  + saleAmount);
  23.     else if (saleAmount > 1000.01 && saleAmount <= 5000.00)
  24.         (shippingCharge = 15.00 + saleAmount);
  25.     else if (saleAmount > 500.01 && saleAmount <= 1000.00)
  26.         (shippingCharge = 10.0 + saleAmount);
  27.     else if (saleAmount > 250.01 && saleAmount <= 500.00)
  28.         (shippingCharge = 8.00 + saleAmount);
  29.     else if (saleAmount > 0.00 && saleAmount <= 250.00)
  30.         (shippingCharge = 5.00 + saleAmount);
  31.     else if 
  32.  
  33. [error]    cout << endl << endl;
  34.     // output
  35.     cout << name << ", your shipping charge is " << shippingCharge << endl;
  36.     cout << setprecision(2) << fixed;
  37.     cout << "Your shipping charge is $" << shippingCharge + saleAmount << endl;
I keep recieving the error code listed below while trying to compile my program, this simple error is causing me nothing but angst trying to figure out what the problem is. If someone could point what the flaw is in my program code I would be forever grateful.
Nov 8 '10 #1
Share this Question
Share on Google+
2 Replies


P: 14
You omitted the control expression for the "else if" just before that cout.

Expand|Select|Wrap|Line Numbers
  1. else if (saleAmount > 0.00 && saleAmount <= 250.00)
  2. (shippingCharge = 5.00 + saleAmount);
  3. else if  // <== error is here
  4.  
  5. [error] cout << endl << endl;
  6. // output
  7. cout << name << ", your shipping charge is " << shippingCharge << endl;
  8. cout << setprecision(2) << fixed;
  9. cout << "Your shipping charge is $" << shippingCharge + saleAmount << endl;
Nov 8 '10 #2

P: 2
Thank you very much for the help, sometimes it takes an extra set of eyes to see where you have gone off course. Once again thank you very much, your assistance was invaluable.
Nov 8 '10 #3

Post your reply

Sign in to post your reply or Sign up for a free account.