Advertisement
Guest User

Toy Shop

a guest
Jan 21st, 2019
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.32 KB | None | 0 0
  1.  
  2. import java.util.Scanner;
  3.  
  4. public class ToyShop {
  5.     public static void main(String[] args) {
  6.         Scanner scan = new Scanner(System.in);
  7.         double tripPrice = Double.parseDouble(scan.nextLine());
  8.         int puzzles = Integer.parseInt(scan.nextLine());
  9.         int dolls = Integer.parseInt(scan.nextLine());
  10.         int bears = Integer.parseInt(scan.nextLine());
  11.         int minions = Integer.parseInt(scan.nextLine());
  12.         int trucks = Integer.parseInt(scan.nextLine());
  13.  
  14.         double puzzlePrice = 2.6;
  15.         double dollPrice = 3;
  16.         double teddyBearPrice = 4.10;
  17.         double minionPrice = 8.2;
  18.         double truckPrice = 2;
  19.  
  20.         int toys = puzzles + dolls + bears + minions + trucks;
  21.         double totalPrice = puzzles * puzzlePrice + dollPrice * dolls + teddyBearPrice * bears + minionPrice * minions + truckPrice * trucks;
  22.  
  23.         if (toys >= 50) {
  24.             totalPrice = totalPrice - totalPrice * 0.25;
  25.         }
  26.  
  27.         totalPrice = totalPrice - totalPrice * 0.10;
  28.  
  29.         if (totalPrice >= tripPrice) {
  30.             totalPrice -= tripPrice;
  31.             System.out.printf("Yes! %.2f lv left.", totalPrice);
  32.         } else {
  33.             totalPrice -= tripPrice;
  34.             System.out.printf("Not enough money! %.2f lv needed.", Math.abs(totalPrice));
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement