Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int amount;
  8.     double ans = 20;
  9.     scanf("%d", &amount);
  10.     if(amount <= 0) {
  11.         printf("You have entered an invalid amount! - please enter a valid number");
  12.         return 0;
  13.     } else if (amount > 50) {
  14.         printf("book limit was exceeded");
  15.         return 0;
  16.     } else if (0 <= amount && amount <= 9) {
  17.         ans -= ans*5/100;
  18.     } else if (10 <= amount && amount <= 14) {
  19.         ans -= ans*10/100;
  20.     } else if (15 <= amount && amount <= 19) {
  21.         ans -= ans*15/100;
  22.     } else if (20 <= amount && amount <= 49) {
  23.         ans -= ans*20/100;
  24.     }
  25.  
  26.     ans *= amount;
  27.  
  28.     printf("%f", ans);
  29.  
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement