Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #include <stdio.h>
  2. int main() {
  3. int amount = 0;
  4. printf("請輸入訂單金額:");
  5. scanf("%d", &amount);
  6. //
  7. double discount = 0.0;
  8. if(amount>0 && amount<=1000){
  9. discount = 1.0;
  10. } else if(amount>1000 && amount<=2000){
  11. discount = 0.95;
  12. } else if(amount>2000 && amount<=3000){
  13. discount = 0.9;
  14. } else if(amount>3000 && amount<=5000){
  15. discount = 0.85;
  16. } else { //????
  17. discount = 0.8;
  18. }
  19. //
  20. amount *= discount; //amount = amount*discount;
  21. printf("折扣後價格=%d\n", amount);
  22. return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement