Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class LiveDemo {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double priceTrip = Double.parseDouble(scanner.nextLine());
- int countPuzzles = Integer.parseInt(scanner.nextLine());
- int countDolls = Integer.parseInt(scanner.nextLine());
- int countBears = Integer.parseInt(scanner.nextLine());
- int countMinions = Integer.parseInt(scanner.nextLine());
- int countTrucks = Integer.parseInt(scanner.nextLine());
- double profit = 0;
- double rent = 0;
- double sum = countPuzzles * 2.60 + countDolls * 3 + countBears * 4.10
- + countMinions * 8.20 + countTrucks * 2;
- int allCount = countPuzzles + countDolls + countBears + countMinions + countTrucks;
- if (allCount >= 50) {
- double discount = 0.25 * sum;
- double endPrice = sum - discount;
- rent = 0.1 * endPrice;
- profit = endPrice - rent;
- } else {
- rent = 0.1 * sum;
- profit = sum - rent;
- }
- if (profit >= priceTrip) {
- System.out.printf("Yes! %.2f lv left.", profit - priceTrip);
- } else {
- System.out.printf("Not enough money! %.2f lv needed.", priceTrip - profit);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement