Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<math.h>
- void main()
- {
- int f;
- while (1) {
- printf("Input the number of task: \n");
- printf("1. Price of the products.\n");
- printf("2. Optimal weight.\n");
- printf("3. Price with sales.\n");
- printf("4. Middle meaning.\n");
- printf("5. Exit.\n");
- scanf_s("%d", &f);
- printf("\n");
- switch (f) {
- case 1:
- int count_notebooks, price_notebook, count_pencils, price_pencil;
- printf("Input the amount of the notebooks: ");
- scanf_s("%d", &count_notebooks);
- printf("Input the price of the notebooks: ");
- scanf_s("%d", &price_notebook);
- printf("Input the amount of the pencils: ");
- scanf_s("%d", &count_pencils);
- printf("Input the price of the pencils: ");
- scanf_s("%d", &price_pencil);
- printf("Total price: %d. Please, cash ur order. \n", (count_notebooks * price_notebook) + (count_pencils * price_pencil));
- printf("\n");
- break;
- case 2:
- int your_height, your_weight, optimal_weight;
- printf("Input ur weight: ");
- scanf_s("%d", &your_weight);
- printf("Input ur height: ");
- scanf_s("%d", &your_height);
- optimal_weight = (your_height - 110) * 1.15;
- if (your_weight > optimal_weight) printf("You need to lose ur weight\n");
- else printf("You need to get fat\n");
- printf("\n");
- break;
- case 3:
- int purchase_amount;
- float aftersale1, aftersale2;
- printf("Input ur purchase amount: ");
- scanf_s("%d", &purchase_amount);
- aftersale1 = purchase_amount - (purchase_amount * 3 / 100);
- aftersale2 = purchase_amount - (purchase_amount * 5 / 100);
- if (500 <= purchase_amount <= 1000) printf("Your sale is 3.\nThe price after sale: %.3f\n", aftersale1);
- else if (purchase_amount >= 1000) printf("Your sale is 5.\nThe price after sale: %.3f\n", aftersale2);
- else printf("You do not have sales");
- printf("\n");
- break;
- case 4:
- int a, n, sum;
- float sr;
- sum = 0;
- n = 0;
- printf("Input 9999 to end the program. \n");
- printf("Input ur numbers: ");
- do {
- scanf_s("%d", &a);
- if (a > 0) {
- sum += a;
- n++;
- }
- } while (a != 9999);
- n--;
- sum -= a;
- sr = sum / n;
- printf("Middle meaning: %3.2f. \n", sr);
- case 5:
- return; break;
- default: printf("Unknown meaning");
- printf("\n");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement