Thursday 30 October 2014

How to calculate the Discount on the Shirts| Display the shirts cost and Discount price|

#include "stdafx.h"
#include <iostream>
using namespace std;

int main()
{ float shirts,rate=12,cost,total_price,disc;
cout<<"WELCOME TO THE HOME OF C PLUS PLUS"<<endl;
cout<<"How many shirts would you like:"<<endl;
cin>>shirts;
cost=rate*shirts;
cout<<"The cost of shirts are:"<<cost<<endl;

if(shirts>=5)
{
disc=(cost*10)/100;
cout<<"Discount:"<<disc<<endl;
total_price=cost-disc;
cout<<"Total price:"<<total_price<<endl;
}
else if(shirts>=11)
{
disc=(cost*15)/100;
cout<<"cost:"<<disc<<endl;
total_price=cost-disc;
cout<<"Total price:"<<total_price<<endl;
}

else if(shirts>=21)
{
disc=(cost*20)/100;
cout<<"cost:"<<disc<<endl;
total_price=cost-disc;
cout<<"Total price:"<<total_price<<endl;
}

else if(shirts>=31)
{
disc=(cost*25)/100;
cout<<"cost:"<<disc<<endl;
total_price=cost-disc;
cout<<"Total price:"<<total_price<<endl;
}
system("pause");



return 0;
}

-------------------------------------------------------------------------------------------

we want to buy 10 shirts ,here the totle cost of the shirts is 120 and the discount is 12.


0 comments:

Post a Comment