Advertisement
GabrielHr00

04. Toy Shop

Mar 17th, 2024
575
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.23 KB | None | 0 0
  1. package _02_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 totalCount = puzzleCount + dollsCount + teddiesCount + minionsCount + trucksCount;
  19.         if(totalCount >= 50) {
  20.             totalSum = totalSum - (totalSum * 0.25);
  21.         }
  22.  
  23.         totalSum = totalSum - (totalSum * 0.10);
  24.  
  25.         double diff = Math.abs(totalSum - tripPrice);
  26.         if(totalSum >= tripPrice) {
  27.             System.out.printf("Yes! %.2f lv left.", diff);
  28.         } else {
  29.             System.out.printf("Not enough money! %.2f lv needed.", diff);
  30.         }
  31.  
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement