Advertisement
Sierra_ONE

Itlog ni Noy Akil

Nov 9th, 2023
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.39 KB | Source Code | 0 0
  1. #include <stdio.h>
  2.  
  3. int main (void){
  4.  
  5.     int eggType, eggOrders, amount;
  6.  
  7.     float typ1 = 15.00, typ2 = 22.50, typ3 = 13.00;
  8.     float typ, change = 0, discount = 0, discprice = 0;
  9.     printf("Itlog ni Noy AKIL!");
  10.     printf("\n[1] #16 @ Php 15.00");
  11.     printf("\n[2] #18 @ Php 22.50");
  12.     printf("\n[3] penoy @ Php 13.00\n");
  13.  
  14.     do{
  15.     printf("Enter your egg type: ");
  16.     scanf("%d", &eggType);
  17.     }
  18.     while (eggType < 1 || eggType > 3);
  19.  
  20.     printf("Enter total egg orders: ");
  21.     scanf("%d", &eggOrders);
  22.     printf("Enter amount: ");
  23.     scanf("%d", &amount);
  24.  
  25.     if (eggType == 1){
  26.         typ = typ1 * eggOrders;
  27.     }
  28.     else if (eggType == 2){
  29.         typ = typ2 * eggOrders;
  30.     }
  31.     else if (eggType == 3){
  32.         typ = typ3 * eggOrders;
  33.     }
  34.  
  35.     if (eggOrders >= 300){
  36.         discount = typ * 0.1;
  37.     }
  38.     else if (eggOrders >= 150){
  39.         discount = typ * 0.05;
  40.     }
  41.  
  42.  
  43.     printf("\nSUMMARY\n");
  44.     printf("Total Cost: Php %.2f", typ);
  45.    printf("\nDiscount: Php %.2f", discount);
  46.  
  47.     change = amount - typ;
  48.  
  49.     if (discount > 0){
  50.         discprice = typ - discount;
  51.         printf("\nDiscounted Price: Php %.2f", discprice);
  52.         change = amount - discprice;
  53.     }
  54.  
  55.  
  56.     if (change > 0){
  57.     printf("\nChange: Php %.2f\n", change);
  58.     } else {
  59.     change *= -1;
  60.     printf("\nChange: (Php %.2f)\n", change);
  61.     }
  62.  
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement