Advertisement
AngelKejov

Untitled

Apr 13th, 2021
162
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class AddBags {
  6.  
  7.     public static void main(String[] args) {
  8.         Scanner sc = new Scanner(System.in);
  9.  
  10.         double priceBagUp20Kg = Double.parseDouble(sc.nextLine());
  11.         double bagKg = Double.parseDouble(sc.nextLine());
  12.         int daysUntilTravel = Integer.parseInt(sc.nextLine());
  13.         int bagCounter = Integer.parseInt(sc.nextLine());
  14.  
  15.         if (bagKg < 10) {
  16.             priceBagUp20Kg = priceBagUp20Kg - (priceBagUp20Kg * 0.20);
  17.         } else if (bagKg >= 10 || bagKg <= 20) {
  18.             priceBagUp20Kg = priceBagUp20Kg - (priceBagUp20Kg * 0.50);
  19.         } else if (bagKg > 20) {
  20.             priceBagUp20Kg = Double.parseDouble(sc.nextLine());
  21.         }
  22.  
  23.         if (daysUntilTravel > 30) {
  24.             priceBagUp20Kg = priceBagUp20Kg + (priceBagUp20Kg * 0.10);
  25.         } else if (daysUntilTravel >= 7 || daysUntilTravel <= 30) {
  26.             priceBagUp20Kg = priceBagUp20Kg + (priceBagUp20Kg * 0.15);
  27.         } else if (daysUntilTravel <= 7) {
  28.             priceBagUp20Kg = priceBagUp20Kg + (priceBagUp20Kg * 0.40);
  29.         }
  30.  
  31.         double totalSum = priceBagUp20Kg * bagCounter;
  32.  
  33.         System.out.printf("The total price of bags is: %.2f lv.", totalSum);
  34.     }
  35. }
  36.  
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement