Advertisement
CoineTre

Toys Shop

Oct 11th, 2020 (edited)
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.33 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.         double puzzlePrice = 2.60;
  10.         int talkingDolls = Integer.parseInt(scanner.nextLine());
  11.         double talkingDollPrice = 3;
  12.         int teddyBears = Integer.parseInt(scanner.nextLine());
  13.         double teddyBearsPrice = 4.10;
  14.         int minions = Integer.parseInt(scanner.nextLine());
  15.         double minionsPrice = 8.20;
  16.         int trucks = Integer.parseInt(scanner.nextLine());
  17.         double trucksPrice = 2;
  18.         double toysNumber = puzzles + talkingDolls + teddyBears + minions + trucks;
  19.         double counter = (puzzles * puzzlePrice) + (talkingDolls * talkingDollPrice) + (teddyBears * teddyBearsPrice) + (minions * minionsPrice) + (trucks * trucksPrice);
  20.  
  21.         counter = counter * 0.9;
  22.  
  23.         if (toysNumber >= 50) {
  24.             counter = counter * 0.75;
  25.         }
  26.  
  27.         if (counter - excursionPrice >= 0){
  28.             System.out.printf("Yes! %.2f lv left.", counter - excursionPrice);
  29.         } else {
  30.             System.out.printf("Not enough money! %.2f lv needed.", excursionPrice - counter);
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement