Advertisement
Guest User

Untitled

a guest
Sep 15th, 2019
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.30 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<math.h>
  3.  
  4. void main()
  5. {
  6.     int f;
  7.     while (1) {
  8.         printf("Input the number of task: \n");
  9.         printf("1. Price of the products.\n");
  10.         printf("2. Optimal weight.\n");
  11.         printf("3. Price with sales.\n");
  12.         printf("4. Middle meaning.\n");
  13.         printf("5. Exit.\n");
  14.         scanf_s("%d", &f);
  15.         printf("\n");
  16.         switch (f) {
  17.         case 1:
  18.             int count_notebooks, price_notebook, count_pencils, price_pencil;
  19.  
  20.             printf("Input the amount of the notebooks: ");
  21.             scanf_s("%d", &count_notebooks);
  22.             printf("Input the price of the notebooks: ");
  23.             scanf_s("%d", &price_notebook);
  24.             printf("Input the amount of the pencils: ");
  25.             scanf_s("%d", &count_pencils);
  26.             printf("Input the price of the pencils: ");
  27.             scanf_s("%d", &price_pencil);
  28.             printf("Total price: %d. Please, cash ur order. \n", (count_notebooks * price_notebook) + (count_pencils * price_pencil));
  29.             printf("\n");
  30.             break;
  31.  
  32.         case 2:
  33.             int your_height, your_weight, optimal_weight;
  34.             printf("Input ur weight: ");
  35.             scanf_s("%d", &your_weight);
  36.             printf("Input ur height: ");
  37.             scanf_s("%d", &your_height);
  38.             optimal_weight = (your_height - 110) * 1.15;
  39.             if (your_weight > optimal_weight) printf("You need to lose ur weight\n");
  40.             else printf("You need to get fat\n");
  41.             printf("\n");
  42.             break;
  43.  
  44.         case 3:
  45.             int purchase_amount;
  46.             float aftersale1, aftersale2;
  47.             printf("Input ur purchase amount: ");
  48.             scanf_s("%d", &purchase_amount);
  49.             aftersale1 = purchase_amount - (purchase_amount * 3 / 100);
  50.             aftersale2 = purchase_amount - (purchase_amount * 5 / 100);
  51.             if (500 <= purchase_amount <= 1000) printf("Your sale is 3.\nThe price after sale: %.3f\n", aftersale1);
  52.             else if (purchase_amount >= 1000) printf("Your sale is 5.\nThe price after sale: %.3f\n", aftersale2);
  53.             else printf("You do not have sales");
  54.             printf("\n");
  55.             break;
  56.        
  57.         case 4:
  58.             int a, n, sum;
  59.             float sr;
  60.  
  61.             sum = 0;
  62.             n = 0;
  63.  
  64.             printf("Input 9999 to end the program. \n");
  65.             printf("Input ur numbers: ");
  66.  
  67.  
  68.  
  69.             do {
  70.                 scanf_s("%d", &a);
  71.  
  72.                 if (a > 0) {
  73.                     sum += a;
  74.                     n++;
  75.                 }
  76.  
  77.             } while (a != 9999);
  78.  
  79.             n--;
  80.             sum -= a;
  81.             sr = sum / n;
  82.             printf("Middle meaning: %3.2f. \n", sr);
  83.  
  84.         case 5:
  85.             return; break;
  86.  
  87.         default: printf("Unknown meaning");
  88.             printf("\n");
  89.         }
  90.     }
  91.  
  92.  
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement