Advertisement
psi_mmobile

Untitled

May 11th, 2022
1,005
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.03 KB | None | 0 0
  1. public class MyClass {
  2.     public static void main(String args[]) {
  3.         java.util.Scanner scanner = new java.util.Scanner(System.in);
  4.         double baggagePriceOver20kg = scanner.nextDouble();
  5.         double baggageWeight = scanner.nextDouble();
  6.         int days = scanner.nextInt();
  7.         int baggageNbr = scanner.nextInt();
  8.        
  9.         double baggageTax = 0.0;
  10.        
  11.         if (baggageWeight < 10) {
  12.             baggageTax = 0.2 * baggagePriceOver20kg;
  13.         } else if (baggageWeight >= 10 && baggageWeight <= 20) {
  14.             baggageTax = 0.5 * baggagePriceOver20kg;
  15.         } else {
  16.             baggageTax = baggagePriceOver20kg;
  17.         }
  18.        
  19.         if (days > 30) {
  20.             baggageTax = 1.1 * baggageTax;
  21.         } else if (days >= 7 && days <= 30) {
  22.             baggageTax = 1.15 * baggageTax;
  23.         } else if (days < 7) {
  24.             baggageTax = 1.4 * baggageTax;
  25.         }
  26.        
  27.         System.out.printf("The total price of bags is: %.2f lv.", baggageNbr * baggageTax);
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement