Advertisement
Spocoman

04. Toy Shop

Aug 24th, 2024
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.19 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class ToyShop {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         double amount = Double.parseDouble(scanner.nextLine());
  8.         int puzzles = Integer.parseInt(scanner.nextLine());
  9.         int dolls = Integer.parseInt(scanner.nextLine());
  10.         int bears = Integer.parseInt(scanner.nextLine());
  11.         int minions = Integer.parseInt(scanner.nextLine());
  12.         int trucks = Integer.parseInt(scanner.nextLine());
  13.  
  14.         double puzzlePrice = puzzles * 2.60;
  15.         double dollsPrice = dolls * 3.00;
  16.         double bearsPrice = bears * 4.10;
  17.         double minionsPrice = minions * 8.20;
  18.         double trucksPrice = trucks * 2.00;
  19.         int toys = puzzles + dolls + bears + minions + trucks;
  20.         double price = puzzlePrice + dollsPrice + bearsPrice + minionsPrice + trucksPrice;
  21.  
  22.         if (toys >= 50) {
  23.             price *= 0.75;
  24.         }
  25.  
  26.         price *= 0.9;
  27.  
  28.         if (price >= amount) {
  29.             System.out.printf("Yes! %.2f lv left.", price - amount);
  30.         } else {
  31.             System.out.printf("Not enough money! %.2f lv needed.", amount - price);
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement