### Undeclared use this function

Getting the following errors:
Line 62 REGULAR_PRICE_PER_SHIRT undeclared [first use this function]
Line 67 Expected '.'expected "cout"

I have checked everything. I think it may be a logic error.

 ``1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859`` ``````#include #include using namespace std; int main() { //Variables for cost and amount charged double numberofshirts, pricepershirt, totalprice, totalcost; // Constants for regular price of shirt const double REGULAR_PRICE_FOR_SHIRT = 12.00; //Get the number of shirts the customer will be buying. cout<<"How many shirts would you like?" <> numberofshirts; //Set the desired output formatting for numbers cout<< setprecision(2) << fixed << showpoint; //Calculate and display cost per shirt and total cost. if (numberofshirts>=5 && numberofshirts<=10) // 5-10 shirts are 10 pct off { pricepershirt = (REGULAR_PRICE_FOR_SHIRT - REGULAR_PRICE_FOR_SHIRT*0.10); totalprice= numberofshirts*pricepershirt; cout<< "The cost per shirt is \$" << pricepershirt << " and the total cost" << "is \$" << totalprice << endl; } else if (numberofshirts>=11 && numberofshirts<=20) // 11-20 15 pct off { pricepershirt = (REGULAR_PRICE_FOR_SHIRT - REGULAR_PRICE_FOR_SHIRT * 0.15); totalprice = numberofshirts*pricepershirt; cout<< "The cost per shirt is \$" << pricepershirt << " and the total "<< "cost is \$" << totalcost << endl; } else if (numberofshirts>=21 && numberofshirts<=30) // 21-30 are 20 pct off { pricepershirt = (REGULAR_PRICE_FOR_SHIRT - REGULAR_PRICE_FOR_SHIRT * 0.20); totalprice = numberofshirts*pricepershirt; cout<< "The cost per shirt is \$" << pricepershirt << " and the total "<< "cost is \$" << totalprice << endl; } else if (numberofshirts>=31) // 31 or more are 25 pct off { pricepershirt = (REGULAR_PRICE_FOR_SHIRT - REGULAR_PRICE_FOR_SHIRT * 0.25); totalprice = numberofshirts*pricepershirt; cout<< "The cost per shirt is \$" << pricepershirt << " and the total "<< "cost is \$" << totalprice << endl; } else if (numberofshirts > 0 && numberofshirts< 5)// no discount { totalprice = (REGULAR_PRICE_PER_SHIRT * numberofshirts); cout<< "The cost per shirt is \$" << REGULAR_PRICE_PER_SHIRT << cout << " and the total cost is \$" << totalprice << endl; } else (numberofshirts < 0) cout<< "Invalid input: Please enter a non-negative integer" << endl; return 0; }``````
Are REGULAR_PRICE_PER_SHIRT and REGULAR_PRICE_FOR_SHIRT supposed to be the same?
`else (numberofshirts < 0)`
is not valid.
use
`else`
Actually just want it to show that REGULAR_PRICE_PER_SHIRT is \$12.00 and multiply that to numberofshirts so it shows a total price.

Yes, thank you EssGeEich, else worked for that error.
 Actually just want it to show that REGULAR_PRICE_PER_SHIRT is \$12.00 and multiply that to numberofshirts so it shows a total price.

Yes, I see that.

I'm saying that REGULAR_PRICE_PER_SHIRT and REGULAR_PRICE_FOR_SHIRT are supposed to be the same thing. You wrote "PER" in the last else if statement when you meant to write "FOR". REGULAR_PRICE_PER_SHIRT appears nowhere else in you code which is why it is undeclared.

Change REGULAR_PRICE_PER_SHIRT to REGULAR_PRICE_FOR_SHIRT and your code should work.
Topic archived. No new replies allowed.