C Program to Calculate total sales amount and discount - IProgramX

Q. Write a program to accept quantity and rate for three items, compute the total sales amount, Also compute and print the discount as follows:
(amount > ____– 20% discount, amount between ___ to _____ -- 15% discount, amount between – ____ to ____ -- 8 % discount.)



Program

#include<stdio.h>
#include<math.h>
int main()
{
int total, qty1,qty2,qty3, price1,price2,price3, discount,t1,t2,t3;
printf("Enter keyboard quantity:");
scanf("%d",&qty1);
printf("\nEnter keyboard price:");
scanf("%d",&price1);
t1=qty1*price1;
printf("\nEnter mouse quantity:");
scanf("%d",&qty2);
printf("\nEnter mouse price:");
scanf("%d",&price2);
t2=qty2*price2;
printf("\nEnter gamepad quantity:");
scanf("%d",&qty3);
printf("\nEnter gamepad price:");
scanf("%d",&price3);
t3=qty3*price3;
total=t1+t2+t3;
printf("total = %d",total);
if(total>7000)
{
discount=(total*0.2);
total=total-discount;
}
else if(total<=7000 && total>5000)
{
discount=(total*0.15);
total=total-discount;
}
else if(total<=5000)
{
discount=(total*0.08);
total=total-discount;
}
printf("\ndiscount= %d",discount);
printf("\nTotal Expense is  Rs=%d ",total);
}

Output:

Enter keyboard quantity:5

Enter keyboard price:342

Enter mouse quantity:6

Enter mouse price:34

Enter gamepad quantity:6

Enter gamepad price:294
total = 3678
discount= 294
Total Expense is  Rs=3384

Post a Comment

0 Comments