Advertisement
desislava_topuzakova

02.ToyShop - 7.05.2017

Mar 25th, 2018
354
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 LiveDemo {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         double priceTrip = Double.parseDouble(scanner.nextLine());
  8.         int countPuzzles = Integer.parseInt(scanner.nextLine());
  9.         int countDolls = Integer.parseInt(scanner.nextLine());
  10.         int countBears = Integer.parseInt(scanner.nextLine());
  11.         int countMinions = Integer.parseInt(scanner.nextLine());
  12.         int countTrucks = Integer.parseInt(scanner.nextLine());
  13.  
  14.         double profit = 0;
  15.         double rent = 0;
  16.         double sum = countPuzzles * 2.60 + countDolls * 3 + countBears * 4.10
  17.                 + countMinions * 8.20 + countTrucks * 2;
  18.  
  19.         int allCount = countPuzzles + countDolls + countBears + countMinions + countTrucks;
  20.  
  21.         if (allCount >= 50) {
  22.             double discount = 0.25 * sum;
  23.             double endPrice = sum - discount;
  24.             rent = 0.1 * endPrice;
  25.             profit = endPrice - rent;
  26.         } else {
  27.              rent = 0.1 * sum;
  28.             profit = sum - rent;
  29.         }
  30.  
  31.         if (profit >= priceTrip) {
  32.             System.out.printf("Yes! %.2f lv left.", profit - priceTrip);
  33.         } else {
  34.             System.out.printf("Not enough money! %.2f lv needed.", priceTrip - profit);
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement