Advertisement
desislava_topuzakova

06. Godzilla vs. Kong

Oct 11th, 2020
2,214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.70 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class GodzillaVsKong_06 {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         //прочитаме входа
  7.         //разходи = цена на декор + цена на статисти
  8.         //цена на декор = 10 % от бюджета
  9.         //цена на статисти = бр.статисти * цена за 1 статист
  10.         //ако статистите са на 150 -> намаление 10% от цена на статисти
  11.         //проверка дали бюджета покрива разходите
  12.  
  13.         double budget = Double.parseDouble(scanner.nextLine());
  14.         int countStatists = Integer.parseInt(scanner.nextLine());
  15.         double pricePerStatist = Double.parseDouble(scanner.nextLine());
  16.  
  17.         double priceDecor = 0.10 * budget;
  18.         double priceStatits = countStatists * pricePerStatist;
  19.         if (countStatists > 150) {
  20.             priceStatits = priceStatits - 0.10 * priceStatits; //0.9 * priceStatists
  21.         }
  22.  
  23.         double expenses = priceDecor + priceStatits; //разходи
  24.         //бюджетът да е достатъчен
  25.         if (budget >= expenses) {
  26.             System.out.println("Action!");
  27.             double leftMoney = budget - expenses;
  28.             System.out.printf("Wingard starts filming with %.2f leva left.", leftMoney);
  29.         } else { //budget < expenses -> Бюджетът не е достатъчен
  30.             System.out.println("Not enough money!");
  31.             double needMoney = expenses - budget;
  32.             System.out.printf("Wingard needs %.2f leva more.", needMoney);
  33.  
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement