Wednesday 2 August 2017

code for calculating discount on shirts

#include"stdio.h"
#include"conio.h"
float a,price,cost_p_shirt,total_cost;
void main()
{
    price=12;
    printf("Enter the amount of shirt\n");
    scanf("%f",&a);
    if((a>=0)&&(a<5))
    {
        cost_p_shirt=price;
        total_cost=cost_p_shirt*a;
        printf("Cost per shirt :%.2f \n",cost_p_shirt);
        printf("Total cost of shirt :% .2f",total_cost);
    }
    else if((a>=5)&&(a<=10))
    {
        cost_p_shirt=price-(price*0.1);
        total_cost=cost_p_shirt*a;
        printf("Cost per shirt :%.2f \n",cost_p_shirt);
        printf("Total cost of shirt :%.2f",total_cost);
    }
    else if((a>=11)&&(a<=20))
    {
        cost_p_shirt=price-(price*0.15);
        total_cost=cost_p_shirt*a;
        printf("Cost per shirt :%.2f \n",cost_p_shirt);
        printf("Total cost of shirt :%.2f",total_cost);
    }
    else if((a>=21)&&(a<=30))
    {
        cost_p_shirt=price-(price*0.2);
        total_cost=cost_p_shirt*a;
        printf("Cost per shirt :%.2f \n",cost_p_shirt);
        printf("Total cost of shirt :%.2f",total_cost);
    }
    else if(a>=31)
    {
        cost_p_shirt=price-(price*0.25);
        total_cost=cost_p_shirt*a;
        printf("Cost per shirt :%.2f \n",cost_p_shirt);
        printf("Total cost of shirt :%.2f",total_cost);
    }
    else
        printf("Invalid Input");
    getch();
}

0 comments: