Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package L02_ConditionalStatements;
- import java.util.Scanner;
- public class P05_GodzillaVsKong {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double budget = Double.parseDouble(scanner.nextLine());
- int countExtras = Integer.parseInt(scanner.nextLine());
- double priceForOnePerson = Double.parseDouble(scanner.nextLine());
- //Пресметнем колко ще платим за дрехите за статистите
- //Пресметнем колко ще платим за декор
- //Проверяваме дали статистите са повече от 150 -> ако са повече имаме 10% отстъпка
- //Пресмятаме общата сума за филма -> декора + цената за дрехите
- //Правим проверка дали бюджетът е достатъчен
- double priceForCloths = countExtras * priceForOnePerson;
- double priceForDecor = budget * 0.1;
- if (countExtras > 150){
- priceForCloths = priceForCloths - priceForCloths * 0.1;//priceForCloths * 0.9
- }
- double finalSum = priceForCloths + priceForDecor;
- double diff = Math.abs(finalSum - budget);
- if(finalSum > budget){
- //System.out.printf("Not enough money!%nWingard needs %.2f leva more.", diff)
- System.out.println("Not enough money!");
- System.out.printf("Wingard needs %.2f leva more.", diff);
- }else {
- System.out.println("Action!");
- System.out.printf("Wingard starts filming with %.2f leva left.", diff);
- }
- }
- }
Advertisement