Advertisement
svephoto

Toy Shop [Java]

Aug 27th, 2020
366
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.35 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class ToyShop {
  4.     public static void main(String[] args) {
  5.         Scanner scan = new Scanner(System.in);
  6.  
  7.         double vacationPrice = Double.parseDouble(scan.nextLine());
  8.         int puzzles = Integer.parseInt(scan.nextLine());
  9.         int dogs = 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 puzzlesPrice = puzzles * 2.6;
  15.         int dogsPrice = dogs * 3;
  16.         double bearsPrice = bears * 4.10;
  17.         double minionsPrice = minions * 8.20;
  18.         int trucksPrice = trucks * 2;
  19.  
  20.         double totalIncomeWithoutRent = (puzzlesPrice + dogsPrice + bearsPrice + minionsPrice + trucksPrice) * 0.90;
  21.         int totalToys = puzzles + dogs + bears + minions + trucks;
  22.  
  23.         if (totalToys >= 50) {
  24.             totalIncomeWithoutRent *= 0.75;
  25.         }
  26.  
  27.         if (totalIncomeWithoutRent < vacationPrice) {
  28.             double moneyNeeded = vacationPrice - totalIncomeWithoutRent;
  29.             System.out.printf("Not enough money! %.2f lv needed.", moneyNeeded);
  30.         } else {
  31.             double moneyNeeded = totalIncomeWithoutRent - vacationPrice;
  32.             System.out.printf("Yes! %.2f lv left.", moneyNeeded);
  33.         }
  34.     }
  35. }
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement