Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class P02AddBags {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double priceAbove20 = Double.parseDouble(scanner.nextLine());
- double baggageKg = Double.parseDouble(scanner.nextLine());
- int days = Integer.parseInt(scanner.nextLine());
- int bags = Integer.parseInt(scanner.nextLine());
- double price = 0;
- if (baggageKg <= 10) {
- price = priceAbove20 * 0.2;
- } else if (baggageKg > 10 && baggageKg <= 20) {
- price = priceAbove20 / 2;
- } else if (baggageKg > 20) {
- price = priceAbove20;
- }
- double priceTotal = 0;
- if (days > 30) {
- priceTotal = price + (price * 0.1);
- } else if (days >= 7 && days <= 30) {
- priceTotal = price + (price * 0.15);
- } else if (days < 7) {
- priceTotal = price + (price * 0.4);
- }
- double total = priceTotal * bags;
- System.out.printf("The total price of bags is: %.2f lv.", total);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement