A cloth showroom has announced the following seasonal discounts on purchase of items:
Purchase Discount
amount Mill cloth Handloom items
0 - 100 - 5%
101 - 200 5% 7.5%
201 - 300 7.5% 10.0%
Above 300 10.0% 15.0%
Write a program using switch and if statements to compute the net amount to be paid by customer.
#include <stdio.h>
void main()
{
int choose, p_amt,pay,discount;
clrscr();
printf("Enter your catagory 1 for mill cloth\n2 for Handloom items and\
purchase amount");
printf("\n0 for End:");
input:
scanf("%d %d",&choose,&p_amt);
if(choose==0)
goto end;
switch(choose)
{
case 1: if(p_amt<=100)
discount=0;
else if(p_amt<=200)
discount=p_amt*0.05;
else
if(p_amt<=300)
discount=p_amt*0.075;
else
if(p_amt>300)
discount=p_amt*0.10;
break;
case 2: if(p_amt<=100)
discount=p_amt*0.05;
else if(p_amt<=200)
discount=p_amt*0.075;
else
if(p_amt<=300)
discount=p_amt*0.10;
else
if(p_amt>300)
discount=p_amt*0.15;
break;
default: printf("Error in choise");
goto end;
}
pay=p_amt-discount;
printf("You have to pay %d",pay);
goto input;
end:
printf("End of Program!");
getch();
}
Purchase Discount
amount Mill cloth Handloom items
0 - 100 - 5%
101 - 200 5% 7.5%
201 - 300 7.5% 10.0%
Above 300 10.0% 15.0%
Write a program using switch and if statements to compute the net amount to be paid by customer.
#include <stdio.h>
void main()
{
int choose, p_amt,pay,discount;
clrscr();
printf("Enter your catagory 1 for mill cloth\n2 for Handloom items and\
purchase amount");
printf("\n0 for End:");
input:
scanf("%d %d",&choose,&p_amt);
if(choose==0)
goto end;
switch(choose)
{
case 1: if(p_amt<=100)
discount=0;
else if(p_amt<=200)
discount=p_amt*0.05;
else
if(p_amt<=300)
discount=p_amt*0.075;
else
if(p_amt>300)
discount=p_amt*0.10;
break;
case 2: if(p_amt<=100)
discount=p_amt*0.05;
else if(p_amt<=200)
discount=p_amt*0.075;
else
if(p_amt<=300)
discount=p_amt*0.10;
else
if(p_amt>300)
discount=p_amt*0.15;
break;
default: printf("Error in choise");
goto end;
}
pay=p_amt-discount;
printf("You have to pay %d",pay);
goto input;
end:
printf("End of Program!");
getch();
}
thanks it works
ReplyDeleteCan I get it in the c language written by Dennis Richard
ReplyDelete