Advertisement
desislava_topuzakova

06. Godzilla vs. Kong

Jun 14th, 2020
1,116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.71 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.         //декор = 0.10 * бюджет
  8.         //облекло = бр.статисти * цена за 1 статист
  9.         //проверка дали ще има остъпка
  10.         //разходи -> проверка дали бюджетът стига
  11.  
  12.         double budget = Double.parseDouble(scanner.nextLine());
  13.         int countStatists = Integer.parseInt(scanner.nextLine());
  14.         double pricePerStatist = Double.parseDouble(scanner.nextLine());
  15.  
  16.         double decorPrice = 0.10 * budget;
  17.         double clothesPrice = countStatists * pricePerStatist;
  18.         //ако бр.статистите > 150
  19.         if (countStatists > 150) {
  20.             clothesPrice = clothesPrice - 0.10 * clothesPrice; //0.9*clothesPrice
  21.         }
  22.  
  23.         double expenses = decorPrice + clothesPrice; //общи разходи за филма
  24.  
  25.         //1. ако е достатъчен бюджетът
  26.         if (budget >= expenses) {
  27.             //достатъчен бюджет
  28.             System.out.println("Action!");
  29.             double leftMoney = budget - expenses;
  30.             System.out.printf("Wingard starts filming with %.2f leva left.", leftMoney);
  31.         } else { //budget < expenses
  32.             //не е достатъчен
  33.             System.out.println("Not enough money!");
  34.             double needMoney = expenses - budget;
  35.             System.out.printf("Wingard needs %.2f leva more.", needMoney);
  36.         }
  37.  
  38.  
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement