Untitled

mail@pastecode.io avatar
unknown
java
2 years ago
1.6 kB
2
Indexable
Never
import java.util.Scanner;

public class ShopForKidsToys {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        double priceOfPuzzel = 2.60;
        double priceOfDoll = 3;
        double priceOfTeddyBear = 4.10;
        double priceOfMinion = 8.20;
        double priceOfToyTruck = 2;
        double discount = 0;

        double priceForExcursion = Double.parseDouble(scan.nextLine());
        int puzzels = Integer.parseInt(scan.nextLine());
        int talkingDolls = Integer.parseInt(scan.nextLine());
        int teddyBears = Integer.parseInt(scan.nextLine());
        int minions = Integer.parseInt(scan.nextLine());
        int toyTrucks = Integer.parseInt(scan.nextLine());

        double sum = puzzels * priceOfPuzzel + talkingDolls * priceOfDoll + teddyBears * priceOfTeddyBear + minions * priceOfMinion + toyTrucks * priceOfToyTruck;
        int numberOfToys = puzzels + talkingDolls + teddyBears + minions + toyTrucks;
        if (numberOfToys > 50){
            discount = sum * 0.25;
        } else {
            discount = 0;
        }
        double endSum = sum - discount;
        double rent = endSum * 0.1;
        double profit = endSum - rent;

        if (profit > priceForExcursion){
            double money = profit - priceForExcursion;
            System.out.printf("Yes! %.2f lv left.", money);
        } else if (profit < priceForExcursion){
            double money = priceForExcursion - profit;
            System.out.printf("Not enough money! %.2f lv needed.", money);
        }
    }
}