Advertisement
kalponikoronno

cashregister

Mar 25th, 2015
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.73 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main() {
  4.  
  5.  
  6.     float itemPrice1 = 0, // Represents the item's price
  7.           itemPrice2 = 0, // Represents secondary item price
  8.           itemQuantity1 = 0, // Accounts for the specified quantity of the item
  9.           itemQuantity2 = 0,
  10.           subTotal1 = 0, // Amount prior to taxAmount
  11.           subTotal2 = 0,
  12.           taxAmount = 0, // Percentage rate of 7% or 0.07
  13.           totalAmount = 0, // Accounts for totalAmount including taxAmount
  14.           cashTendered = 0, // Amount given towards totalAmount price
  15.           change = 0; // Deductable given after payment
  16.  
  17. // Implementation
  18.  
  19.     printf("Enter the quantity and price for Paint :");
  20.     scanf("%f %f", &itemQuantity1, &itemPrice1);
  21.     printf("Enter the quantity and price for Blue Brush :");
  22.     scanf("%f %f", &itemQuantity2, &itemPrice2);
  23.  
  24.  
  25.  
  26.     subTotal1 = itemPrice1 * itemQuantity1;
  27.     subTotal2 = itemPrice2 * itemQuantity2;
  28.     taxAmount = 0.07*(subTotal1 + subTotal2);
  29.     totalAmount = subTotal1 + subTotal2 + taxAmount;
  30.     change = cashTendered - totalAmount;
  31.  
  32. // Program's output results
  33.  
  34.     printf("Your total is: %.2f", totalAmount);
  35.     scanf("%f", totalAmount);
  36.     printf ("Here is your receipt :\n");
  37.     printf ("JcPenny Stores\t\t\n");
  38.     printf ("Dayview Mall\t\t\n");
  39.     printf ("Article 1\t\t\t 1 @", itemPrice1, subTotal1);
  40.     printf ("Article 2\t\t\t 2 @", itemPrice2, subTotal2);
  41.     printf("Sub Total\t\t%.2f\n", subTotal1+subTotal2);
  42.     printf("Sales Tax(7%%)\t\t%.2f\n", taxAmount);
  43.     printf("Total Amount\t\t\t%.2f\n", totalAmount);
  44.     printf("Cash Tendered\t\t\t%.2f\n", cashTendered);
  45.     printf("Change\t%.2f\n\n", change);
  46.     printf("Thank you for shopping with us!");
  47.  
  48.     return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement