Advertisement
pedroschmid

Untitled

Aug 17th, 2019
345
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. #include <stdlib.h>
  4.  
  5. #include <math.h>
  6.  
  7. int main() {
  8. float productPrice, reajustedPrice, percentageValue;
  9. char switchChoose, operationChoose;
  10.  
  11. printf("if you want to add the percentage value type YES if not type NOT\n");
  12. scanf("%c", &operationChoose);
  13.  
  14. if (operationChoose == 'YES') {
  15. printf("Enter percentage value\n");
  16. scanf("%f", &percentageValue);
  17.  
  18. printf("A to Addition\nD to Descount\n");
  19. scanf("%c", &switchChoose);
  20.  
  21. switch (switchChoose) {
  22. case 'A':
  23. printf("Entering case A...\n");
  24. printf("Enter product price:\n");
  25. scanf("%f", &productPrice);
  26.  
  27. reajustedPrice = productPrice + (productPrice * (percentageValue / 100));
  28. printf("Total price: %.2f", reajustedPrice);
  29. break;
  30.  
  31. case 'D':
  32. printf("Entering case D...\n");
  33. printf("Enter product price:\n");
  34. scanf("%f", &productPrice);
  35.  
  36. reajustedPrice = productPrice - (productPrice * (percentageValue / 100));
  37. printf("Total price: %.2f", reajustedPrice);
  38. break;
  39. }
  40. } else {
  41. printf("A to Addition\nD to Descount\n");
  42. scanf("%c", &switchChoose);
  43.  
  44. switch (switchChoose) {
  45. case 'A':
  46. printf("Entering case A...\n");
  47. printf("Enter product price:\n");
  48. scanf("%f", &productPrice);
  49.  
  50. reajustedPrice = productPrice + (productPrice * 0.03);
  51. printf("Total price: %.2f", reajustedPrice);
  52. break;
  53.  
  54. case 'D':
  55. printf("Entering case D...\n");
  56. printf("Enter product price:\n");
  57. scanf("%f", &productPrice);
  58.  
  59. reajustedPrice = productPrice - (productPrice * 0.03);
  60. printf("Total price: %.2f", reajustedPrice);
  61. break;
  62. }
  63. }
  64. return 0;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement