Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class ToyShop_07 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- //обща печалба = (бр. пъзели * 2.60) + (бр.кукли * 3) + (бр. мечета * 4.10)
- // + (бр. миньоните * 8.20) + (бр. камиони * 2)
- //брой на играчки = бр. пъзели + бр. кукли + бр. мечета + бр. миньоните + бр. камиони
- // проверка дали прави остъпка -> бр. играчки + >= 50
- // изваждаме наем
- //проверка дали печалбата покрива цената на екскурзията
- double priceTrip = Double.parseDouble(scanner.nextLine());
- int countPuzzles = Integer.parseInt(scanner.nextLine());
- int countDolls = Integer.parseInt(scanner.nextLine());
- int countBears = Integer.parseInt(scanner.nextLine());
- int countMinions = Integer.parseInt(scanner.nextLine());
- int countTrucks = Integer.parseInt(scanner.nextLine());
- double profit = (countPuzzles * 2.60) + (countDolls * 3) + (countBears * 4.10) + (countMinions * 8.20) + (countTrucks * 2);
- int countToys = countPuzzles + countDolls + countBears + countMinions + countTrucks;
- //остъпка
- if(countToys >= 50){
- profit = profit - 0.25 * profit;
- //profit = profit * 0.75
- //profit *= 0.75
- }
- //наем -> намаля цената с 10%
- profit = profit - 0.10 * profit;
- //profit = profit * 0.9 -> profit *= 0.9
- if(profit >= priceTrip) {
- double leftMoney = profit - priceTrip;
- System.out.printf("Yes! %.2f lv left.", leftMoney);
- } else { //profit < priceTrip
- double needMoney = priceTrip - profit;
- System.out.printf("Not enough money! %.2f lv needed.", needMoney);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment