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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Otis Monroe
    New Member
    • Nov 2010
    • 2

    #1

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

    Code:
     #include <iostream>
    #include <iomanip>
    #include <string>
    
    using namespace std;
    
    int main()
    {
    	//declare variables
    	string name = " ";
    	double saleAmount = 0.0;
    	double shippingCharge = 0.0;
    
    	// ask  user for input
    	cout << "Plese Enter sales amount: ";
    	cin >> saleAmount;
    	cout << endl << endl;
    
    	// calculate shipping charge
    	cout << "Calculating shipping charge" << endl;
    	if (saleAmount > 5,000.00)
    		(shippingCharge = 20.00  + saleAmount);
    	else if (saleAmount > 1000.01 && saleAmount <= 5000.00)
    		(shippingCharge = 15.00 + saleAmount);
    	else if (saleAmount > 500.01 && saleAmount <= 1000.00)
    		(shippingCharge = 10.0 + saleAmount);
    	else if (saleAmount > 250.01 && saleAmount <= 500.00)
    		(shippingCharge = 8.00 + saleAmount);
    	else if (saleAmount > 0.00 && saleAmount <= 250.00)
    		(shippingCharge = 5.00 + saleAmount);
    	else if 
    
    [error]	cout << endl << endl;
    	// output
    	cout << name << ", your shipping charge is " << shippingCharge << endl;
    	cout << setprecision(2) << fixed;
    	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.
    Last edited by acoder; Nov 8 '10, 11:50 AM. Reason: Fixed code tags
  • rstiltskin
    New Member
    • Feb 2010
    • 14

    #2
    You omitted the control expression for the "else if" just before that cout.

    Code:
    else if (saleAmount > 0.00 && saleAmount <= 250.00)
    (shippingCharge = 5.00 + saleAmount);
    else if  // <== error is here
    
    [error] cout << endl << endl;
    // output
    cout << name << ", your shipping charge is " << shippingCharge << endl;
    cout << setprecision(2) << fixed;
    cout << "Your shipping charge is $" << shippingCharge + saleAmount << endl;

    Comment

    • Otis Monroe
      New Member
      • Nov 2010
      • 2

      #3
      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.

      Comment

      Working...