C++ tshirt program

I've go this code that I need to use a Named Constant for the price of a t-shirt.

I've already done the code from a previous lab for college and I'm not sure how to proceed.

Here is the code:

int main()
{
int tno, price=12,cost;
float discount;
cout<<"type the number of shirts which you want to buy:";
cin>>tno;
if(tno>0 && tno<5)
cout<<"the cost per shirt is 12$ and the total cost is "<<tno*12<<endl;
else if(tno>=5 && tno<=10)
{
cost=tno*price;
discount=(float)cost/100*10;
cost= (cost- discount);
cout<<"the cost per shirt is 12$ and the total cost with 10 % discount is "<<cost<<"\n";
}
else if(tno>=11 && tno<=20)
{
cost=tno*price;
discount=(cost/100)*15;
cost= (cost- discount);
cout<<"the cost per shirt is 12$ and the total cost with 15 % discount is "<<cost<<"\n";
}
else if(tno>=21 && tno<=30)
{
cost=tno*price;
discount=(cost/100)*20;
cost= (cost- discount);
cout<<"the cost per shirt is 12$ and the total cost with 20 % discount is"<<cost<<"\n";
}
else if(tno>=31)
{
cost=tno*price;
discount=(cost/100*25);
cost= (cost- discount);
cout<<"the cost per shirt is 12$ and the total cost with 25 % discount is "<<cost<<"\n";
}
else
cout<<"you typed a negative value."<<"\n";

system("pause");
return 0;
}

not asking to have this done for me just a hint at where to put the Named Constant
A constant is a variable that has a "const" before the type during initialization.

My best guess says that you just need to do const int price = 12;, you could do it outside the main if you want to.
thanks that works just fine poteto :-)
Topic archived. No new replies allowed.