Advertisement
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 amount = Double.parseDouble(scanner.nextLine());
- int puzzles = Integer.parseInt(scanner.nextLine());
- int dolls = Integer.parseInt(scanner.nextLine());
- int bears = Integer.parseInt(scanner.nextLine());
- int minions = Integer.parseInt(scanner.nextLine());
- int trucks = Integer.parseInt(scanner.nextLine());
- double puzzlePrice = puzzles * 2.60;
- double dollsPrice = dolls * 3.00;
- double bearsPrice = bears * 4.10;
- double minionsPrice = minions * 8.20;
- double trucksPrice = trucks * 2.00;
- int toys = puzzles + dolls + bears + minions + trucks;
- double price = puzzlePrice + dollsPrice + bearsPrice + minionsPrice + trucksPrice;
- if (toys >= 50) {
- price *= 0.75;
- }
- price *= 0.9;
- if (price >= amount) {
- System.out.printf("Yes! %.2f lv left.", price - amount);
- } else {
- System.out.printf("Not enough money! %.2f lv needed.", amount - price);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement