Advertisement
GabrielHr00

04. Toy Shop

May 21st, 2023
329
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.31 KB | None | 0 0
  1. package S2_ConditionalStatements;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class ToyShop {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.         double tripPrice = Double.parseDouble(scanner.nextLine());
  9.         int puzzleCount = Integer.parseInt(scanner.nextLine());
  10.         int dollsCount = Integer.parseInt(scanner.nextLine());
  11.         int teddiesCount = Integer.parseInt(scanner.nextLine());
  12.         int minionsCount = Integer.parseInt(scanner.nextLine());
  13.         int trucksCount = Integer.parseInt(scanner.nextLine());
  14.  
  15.         double totalSum = (2.60 * puzzleCount) + (3.0 * dollsCount) + (4.10 * teddiesCount)
  16.                 + (8.20 * minionsCount) + (2.0 * trucksCount);
  17.  
  18.         int countToys = puzzleCount + dollsCount + teddiesCount + minionsCount + trucksCount;
  19.         if (countToys >= 50) {
  20.             //totalSum = totalSum - (totalSum * 0.25);
  21.             totalSum = totalSum * 0.75;
  22.         }
  23.  
  24.         //totalSum = totalSum - (totalSum * 0.10);
  25.         totalSum = totalSum * 0.90;
  26.  
  27.         double diff = Math.abs(totalSum - tripPrice);
  28.         if (totalSum >= tripPrice) {
  29.             System.out.printf("Yes! %.2f lv left.", diff);
  30.         } else {
  31.             System.out.printf("Not enough money! %.2f lv needed.", diff);
  32.         }
  33.     }
  34. }
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement