myrdok123

05. Godzilla vs. Kong

Apr 30th, 2023
1,044
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.71 KB | None | 0 0
  1. package L02_ConditionalStatements;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class P05_GodzillaVsKong {
  6.  
  7.     public static void main(String[] args) {
  8.         Scanner scanner = new Scanner(System.in);
  9.  
  10.  
  11.         double budget = Double.parseDouble(scanner.nextLine());
  12.         int countExtras = Integer.parseInt(scanner.nextLine());
  13.         double priceForOnePerson = Double.parseDouble(scanner.nextLine());
  14.  
  15.         //Пресметнем колко ще платим за дрехите за статистите
  16.         //Пресметнем колко ще платим за декор
  17.         //Проверяваме дали статистите са повече от 150 -> ако са повече имаме 10% отстъпка
  18.         //Пресмятаме общата сума за филма -> декора + цената за дрехите
  19.         //Правим проверка дали бюджетът е достатъчен
  20.  
  21.  
  22.         double priceForCloths = countExtras * priceForOnePerson;
  23.         double priceForDecor = budget * 0.1;
  24.  
  25.         if (countExtras > 150){
  26.             priceForCloths = priceForCloths - priceForCloths * 0.1;//priceForCloths * 0.9
  27.         }
  28.  
  29.         double finalSum = priceForCloths + priceForDecor;
  30.         double diff = Math.abs(finalSum - budget);
  31.  
  32.         if(finalSum > budget){
  33.  
  34.             //System.out.printf("Not enough money!%nWingard needs %.2f leva more.", diff)
  35.             System.out.println("Not enough money!");
  36.             System.out.printf("Wingard needs %.2f leva more.", diff);
  37.         }else {
  38.             System.out.println("Action!");
  39.             System.out.printf("Wingard starts filming with %.2f leva left.", diff);
  40.         }
  41.  
  42.  
  43.  
  44.     }
  45. }
  46.  
Advertisement
Comments
Add Comment
Please, Sign In to add comment