1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define DISCOUNT_10 10.00
#define DISCOUNT_12 12.00
int main(void)
{
int customer;
double purchase;
double discount2;
double discounttl;
double salestax;
double purchasettl;
printf("Is customer a teacher (Y/N) ?>");
scanf("%c", &customer);
printf("\nEnter total purchases:>\n");
scanf ("%lf", &purchase);
if (customer == 'Y' && purchase > 100.00) {
discount2 = purchase * 0.12;
discounttl = purchase * 0.88;
salestax = discounttl * 0.05;
purchasettl = discounttl * 1.05;
printf("\nTotal purchases $%6.2f\n", purchase);
printf("Teacher's discount(%d%%) %6.2lf\n", DISCOUNT_12, discount2);
printf("Discounted total %6.2lf\n", discounttl);
printf("Sales tax(5%%) %6.2lf\n", salestax);
printf("Total %6.2lf\n", purchasettl);
}
else
{
discount2 = purchase * 0.10;
discounttl = purchase * 0.90;
purchasettl = discounttl * 1.05;
}
printf("\nTotal purchases $%6.2lf\n", purchase);
printf("Teacher's discount (%d%%) %6.2lf\n", DISCOUNT_10, discount2);
printf("Discounted total %6.2lf\n", discounttl);
printf("Sales tax(5%) %6.2lf\n", salestax);
printf("Total %6.2lf\n", purchasettl);
if (customer == 'N') {
purchasettl = purchase * 1.05;
printf("\nTotal purchases $%.2f\n", purchase);
printf("Sales tax(5%%) %.2f\n", salestax);
printf("Total %.2f", purchasettl);
}
system ("pause");
return (0);
}
|