Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- int main() {
- float productPrice, reajustedPrice, percentageValue;
- char switchChoose, operationChoose;
- printf("if you want to add the percentage value type YES if not type NOT\n");
- scanf("%c", &operationChoose);
- if (operationChoose == 'YES') {
- printf("Enter percentage value\n");
- scanf("%f", &percentageValue);
- printf("A to Addition\nD to Descount\n");
- scanf("%c", &switchChoose);
- switch (switchChoose) {
- case 'A':
- printf("Entering case A...\n");
- printf("Enter product price:\n");
- scanf("%f", &productPrice);
- reajustedPrice = productPrice + (productPrice * (percentageValue / 100));
- printf("Total price: %.2f", reajustedPrice);
- break;
- case 'D':
- printf("Entering case D...\n");
- printf("Enter product price:\n");
- scanf("%f", &productPrice);
- reajustedPrice = productPrice - (productPrice * (percentageValue / 100));
- printf("Total price: %.2f", reajustedPrice);
- break;
- }
- } else {
- printf("A to Addition\nD to Descount\n");
- scanf("%c", &switchChoose);
- switch (switchChoose) {
- case 'A':
- printf("Entering case A...\n");
- printf("Enter product price:\n");
- scanf("%f", &productPrice);
- reajustedPrice = productPrice + (productPrice * 0.03);
- printf("Total price: %.2f", reajustedPrice);
- break;
- case 'D':
- printf("Entering case D...\n");
- printf("Enter product price:\n");
- scanf("%f", &productPrice);
- reajustedPrice = productPrice - (productPrice * 0.03);
- printf("Total price: %.2f", reajustedPrice);
- break;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement