Advertisement
MoPhreak

ToyShop

Sep 18th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.21 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 trip = Double.parseDouble(scanner.nextLine());
  7.         double puzzle = Double.parseDouble(scanner.nextLine());
  8.         double dolls = Double.parseDouble(scanner.nextLine());
  9.         double bear = Double.parseDouble(scanner.nextLine());
  10.         double minion = Double.parseDouble(scanner.nextLine());
  11.         double truck = Double.parseDouble(scanner.nextLine());
  12.         double allpuzzle = puzzle * 2.6;
  13.         double alldolls = dolls * 3;
  14.         double allbear = bear * 4.1;
  15.         double allminions = minion * 8.2;
  16.         double alltruck = truck * 2;
  17.         double toys = puzzle + dolls + bear + minion + truck;
  18.         double total = allpuzzle + alldolls + allbear + allminions + alltruck;
  19.  
  20.         if (toys >= 50) {
  21.             total = total - (total * 0.25);
  22.         }
  23.         double finalSum = (total - total * 0.1);
  24.         if (finalSum >= trip) {
  25.             System.out.printf("Yes! %.2f lv left.", finalSum - trip);
  26.         } else {
  27.             System.out.printf("Not enough money! %.2f lv needed.", trip - finalSum);
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement