Advertisement
kristiyanasimeonova

Untitled

Sep 16th, 2019
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.73 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 tripPrice = Double.parseDouble(scanner.nextLine());
  7.         int countOfPuzzles = Integer.parseInt(scanner.nextLine());
  8.         int countOfDolls = Integer.parseInt(scanner.nextLine());
  9.         int countOfBears = Integer.parseInt(scanner.nextLine());
  10.         int countOfMinions = Integer.parseInt(scanner.nextLine());
  11.         int countOfTrucks = Integer.parseInt(scanner.nextLine());
  12.         int countOfToys = countOfBears + countOfDolls + countOfMinions + countOfPuzzles + countOfTrucks;
  13.         double prices = countOfPuzzles * 2.60 + countOfDolls * 3 + countOfMinions * 8.20 + countOfTrucks * 2 + countOfBears * 4.10;
  14.         double priceTotal = 0.00;
  15.         double rent = 0.10;
  16.         double priceFinal = 0.00;
  17.         if (countOfToys > 50) {
  18.             priceTotal = prices * 0.75;
  19.             priceFinal = priceTotal -(priceTotal*rent);
  20.             double moneyLeft = Math.abs(priceFinal - tripPrice);
  21.             if (priceFinal >= tripPrice) {
  22.                 System.out.printf("Yes! %.2f lv left.", moneyLeft);
  23.             } else {
  24.                 System.out.printf("Not enough money! %.2f lv needed.", moneyLeft);
  25.             }
  26.         } else if (countOfToys < 50) {
  27.             priceTotal = prices;
  28.             priceFinal = priceTotal- (priceTotal*rent);
  29.             double moneyLeft = Math.abs(priceFinal - tripPrice);
  30.             if (priceFinal >= tripPrice) {
  31.                 System.out.printf("Yes! %.2f lv left.", moneyLeft);
  32.             } else {
  33.                 System.out.printf("Not enough money! %.2f lv needed.", moneyLeft);
  34.             }
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement