Advertisement
Guest User

Toy shop

a guest
Jan 20th, 2020
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.07 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.  
  7.         double priceTrip = Double.parseDouble(scanner.nextLine());
  8.         int numPuzzle = Integer.parseInt(scanner.nextLine());
  9.         int numDolls = Integer.parseInt(scanner.nextLine());
  10.         int numBears = Integer.parseInt(scanner.nextLine());
  11.         int numMinion = Integer.parseInt(scanner.nextLine());
  12.         int numTruck = Integer.parseInt(scanner.nextLine());
  13.  
  14.         double allToys = numPuzzle + numDolls + numBears + numMinion + numTruck;
  15.         double  allSum = (numPuzzle * 2.60) + (numDolls * 3) + ( numBears * 4.10) + (numMinion * 8.20) + (numTruck * 2);
  16.  
  17.  
  18.         if ( allToys >= 50 ){
  19.             allSum = allSum * 0.75;
  20.         }
  21.         allSum = allSum * 0.90;
  22.  
  23.         if ( allSum >= priceTrip) {
  24.             System.out.printf("Yes! %.2f lv left.", allSum - priceTrip);
  25.         }else {
  26.             System.out.printf("Not enough money! %.2f lv needed.", priceTrip - allSum);
  27.         }
  28.  
  29.  
  30.  
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement