Advertisement
nbzhk

P02AddBags

Jan 12th, 2023 (edited)
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class P02AddBags {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. double priceAbove20 = Double.parseDouble(scanner.nextLine());
  8. double baggageKg = Double.parseDouble(scanner.nextLine());
  9. int days = Integer.parseInt(scanner.nextLine());
  10. int bags = Integer.parseInt(scanner.nextLine());
  11.  
  12. double price = 0;
  13.  
  14.  
  15. if (baggageKg <= 10) {
  16. price = priceAbove20 * 0.2;
  17. } else if (baggageKg > 10 && baggageKg <= 20) {
  18. price = priceAbove20 / 2;
  19. } else if (baggageKg > 20) {
  20. price = priceAbove20;
  21. }
  22.  
  23. double priceTotal = 0;
  24.  
  25. if (days > 30) {
  26. priceTotal = price + (price * 0.1);
  27. } else if (days >= 7 && days <= 30) {
  28. priceTotal = price + (price * 0.15);
  29. } else if (days < 7) {
  30. priceTotal = price + (price * 0.4);
  31. }
  32. double total = priceTotal * bags;
  33. System.out.printf("The total price of bags is: %.2f lv.", total);
  34. }
  35. }
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement