#include<iostream>
#include<iomanip>
usingnamespace std;
int main()
{
//Variables for cost and amount charged
double numberofshirts, pricepershirt, totalprice, totalcost;
// Constants for regular price of shirt
constdouble REGULAR_PRICE_FOR_SHIRT = 12.00;
//Get the number of shirts the customer will be buying.
cout<<"How many shirts would you like?" <<endl;
cin>> 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;
}
elseif (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;
}
elseif (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;
}
elseif (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;
}
elseif (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;
}
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.