Advertisement
Guest User

Untitled

a guest
Apr 27th, 2020
822
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.49 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class ToyShop {
  4.     public static void main(String[] args) {
  5.  
  6.         Scanner scanner = new Scanner(System.in);
  7.  
  8.  
  9.  
  10.         double excursionPrice = Double.parseDouble(scanner.nextLine());
  11.         int numberOfPuzzles = Integer.parseInt(scanner.nextLine());
  12.         int numberOfDolls = Integer.parseInt(scanner.nextLine());
  13.         int numberOfBears = Integer.parseInt(scanner.nextLine());
  14.         int numberOfMinions = Integer.parseInt(scanner.nextLine());
  15.         int numberOfTrucks = Integer.parseInt(scanner.nextLine());
  16.         int totalToys = numberOfBears + numberOfDolls + numberOfMinions + numberOfPuzzles + numberOfTrucks;
  17.  
  18.         double puzzleProfit = numberOfPuzzles * 2.6;
  19.         double dollsProfit = numberOfDolls * 3;
  20.         double bearsProfit = numberOfBears * 4.1;
  21.         double minionsProfit = numberOfMinions * 8.2;
  22.         double trucksProfit = numberOfTrucks * 2;
  23.  
  24.         double totalProfit = puzzleProfit + dollsProfit + bearsProfit + minionsProfit + trucksProfit;
  25.  
  26.         if (totalToys >= 50) {
  27.             double discount = totalProfit * 0.25;
  28.             totalProfit = totalProfit - discount;
  29.         }
  30.  
  31.         totalProfit = totalProfit * 0.9;
  32.         totalProfit = totalProfit - excursionPrice;
  33.  
  34.         if (totalProfit >= 0){
  35.             System.out.printf("Yes! %.2f lv left.", totalProfit);
  36.         } else {
  37.             System.out.printf("Not enough money! %.2f lv needed.", Math.abs(totalProfit));
  38.         }
  39.  
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement