Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #define IPOD 148
- #define IPAD 288
- #define TOTAL 1020
- int main () {
- int ipod, ipad;
- float total, discount;
- printf("%*s%s%*s\n", 10, "", "Welcome to Topcare supermarket", 10, "");
- printf("Please enter the numbers of products below that you would buy:\n");
- printf("- Ipod: ");
- scanf("%d", &ipod);
- printf("- Ipad: ");
- scanf("%d", &ipad);
- printf("\nTOPCARE SUPERMARKET - BILL\n");
- printf("---------------------------\n");
- printf("%-*s%-*s%-*s\n", 5, "Qty", 15, "Product", 7, "Total");
- printf("---------------------------\n");
- printf("%-*d%-*s$%-*d\n", 5, ipod, 15, "Ipod", 6, ipod*IPOD);
- printf("%-*d%-*s$%-*d\n\n", 5, ipad, 15, "Ipad", 6, ipad*IPAD);
- total = ipod*IPOD + ipad*IPAD;
- printf("Net: $%.2f\n\n", total);
- printf("Your discount is %.0f%%\n", (discount = 10 * ((total > TOTAL) || ((ipod >= 3) && (ipad > 2)))));
- printf("You pay $%.2f (-$%.2f) = $%.2f\n", total, total*discount/100, total*(1+discount/100));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement