Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class ToyShop {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double excursionPrice = Double.parseDouble(scanner.nextLine());
- int puzzles = Integer.parseInt(scanner.nextLine());
- int talkingDolls = Integer.parseInt(scanner.nextLine());
- int teddyBears = Integer.parseInt(scanner.nextLine());
- int minions = Integer.parseInt(scanner.nextLine());
- int trucks = Integer.parseInt(scanner.nextLine());
- double toysNumber = puzzles + talkingDolls + teddyBears + minions + trucks;
- double totalMoney = (puzzles * 2.60) + (talkingDolls * 3.0) + (teddyBears * 4.10) + (minions * 8.20) + (trucks * 2);
- totalMoney *= 0.9;
- totalMoney = toysNumber >= 50 ? totalMoney * 0.75 : totalMoney;
- String printResult = totalMoney - excursionPrice >= 0 ? String.format("Yes! %.2f lv left.", totalMoney - excursionPrice) :
- String.format("Not enough money! %.2f lv needed.", excursionPrice - totalMoney);
- System.out.println(printResult);
- }
- }
Add Comment
Please, Sign In to add comment