Advertisement
desislava_topuzakova

07. Toy Shop

Apr 10th, 2021
787
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.10 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 priceExcursion = Double.parseDouble(scanner.nextLine());
  8.         int puzzles = Integer.parseInt(scanner.nextLine());
  9.         int dolls = Integer.parseInt(scanner.nextLine());
  10.         int teddies = Integer.parseInt(scanner.nextLine());
  11.         int minions = Integer.parseInt(scanner.nextLine());
  12.         int trucks = Integer.parseInt(scanner.nextLine());
  13.  
  14.         int totalCount = puzzles + dolls + teddies + minions + trucks;
  15.  
  16.         double totalProfit = puzzles * 2.60 + dolls * 3 + teddies * 4.10
  17.                 + minions * 8.20 + trucks * 2;
  18.  
  19.         if (totalCount >= 50) {
  20.             totalProfit *= 0.75;
  21.         }
  22.  
  23.         totalProfit *= 0.9;
  24.  
  25.         if (priceExcursion <= totalProfit) {
  26.             System.out.printf("Yes! %.2f lv left.", totalProfit - priceExcursion);
  27.         } else {
  28.             System.out.printf("Not enough money! %.2f lv needed.",
  29.                     priceExcursion - totalProfit);
  30.         }
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement