CoineTre

Toy Shop

Oct 11th, 2020 (edited)
8
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.11 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.         double excursionPrice = Double.parseDouble(scanner.nextLine());
  7.         int puzzles = Integer.parseInt(scanner.nextLine());
  8.        
  9.         int talkingDolls = Integer.parseInt(scanner.nextLine());
  10.         int teddyBears = Integer.parseInt(scanner.nextLine());
  11.         int minions = Integer.parseInt(scanner.nextLine());
  12.         int trucks = Integer.parseInt(scanner.nextLine());
  13.         double toysNumber = puzzles + talkingDolls + teddyBears + minions + trucks;
  14.         double totalMoney = (puzzles * 2.60) + (talkingDolls * 3.0) + (teddyBears * 4.10) + (minions * 8.20) + (trucks * 2);
  15.         totalMoney *= 0.9;
  16.         totalMoney = toysNumber >= 50 ? totalMoney * 0.75 : totalMoney;
  17.         String printResult = totalMoney - excursionPrice >= 0 ? String.format("Yes! %.2f lv left.", totalMoney - excursionPrice) :
  18.                 String.format("Not enough money! %.2f lv needed.", excursionPrice - totalMoney);
  19.         System.out.println(printResult);
  20.     }
  21. }
Add Comment
Please, Sign In to add comment