desislava_topuzakova

07. Toy Shop

Apr 14th, 2021
640
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.01 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class ToyShop_07 {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         //обща печалба = (бр. пъзели * 2.60) + (бр.кукли * 3) + (бр. мечета * 4.10)
  7.         // + (бр. миньоните * 8.20) + (бр. камиони * 2)
  8.         //брой на играчки = бр. пъзели + бр. кукли + бр. мечета + бр. миньоните + бр. камиони
  9.         // проверка дали прави остъпка -> бр. играчки +  >= 50
  10.         // изваждаме наем
  11.         //проверка дали печалбата покрива цената на екскурзията
  12.  
  13.         double priceTrip = Double.parseDouble(scanner.nextLine());
  14.         int countPuzzles = Integer.parseInt(scanner.nextLine());
  15.         int countDolls = Integer.parseInt(scanner.nextLine());
  16.         int countBears = Integer.parseInt(scanner.nextLine());
  17.         int countMinions = Integer.parseInt(scanner.nextLine());
  18.         int countTrucks = Integer.parseInt(scanner.nextLine());
  19.  
  20.         double profit = (countPuzzles * 2.60) + (countDolls * 3) + (countBears * 4.10) + (countMinions * 8.20) + (countTrucks * 2);
  21.         int countToys = countPuzzles + countDolls + countBears + countMinions + countTrucks;
  22.  
  23.         //остъпка
  24.         if(countToys >= 50){
  25.             profit = profit - 0.25 * profit;
  26.             //profit = profit * 0.75
  27.             //profit *= 0.75
  28.         }
  29.  
  30.         //наем -> намаля цената с 10%
  31.         profit = profit - 0.10 * profit;
  32.         //profit = profit * 0.9 -> profit *= 0.9
  33.  
  34.         if(profit >= priceTrip) {
  35.             double leftMoney = profit - priceTrip;
  36.             System.out.printf("Yes! %.2f lv left.", leftMoney);
  37.         } else { //profit < priceTrip
  38.             double needMoney = priceTrip - profit;
  39.             System.out.printf("Not enough money! %.2f lv needed.", needMoney);
  40.         }
  41.  
  42.  
  43.  
  44.     }
  45. }
  46.  
Advertisement
Add Comment
Please, Sign In to add comment