Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class ExamPreparation {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- //стоп: бюджетът < 0 или ACTION
- double budget = Double.parseDouble(scanner.nextLine());
- //command -> актьор или ACTION
- //спираме: command == ACTION
- //продължаваме: command != ACTION
- String command = scanner.nextLine();
- while(!command.equals("ACTION")) {
- //АКТЬОР
- String actorName = command;
- double salary = 0;
- //над 15 символа -> 20% от бюджета
- //под 15 символа -> от конзолата
- if(actorName.length() > 15) {
- salary = 0.2 * budget;
- } else {
- salary = Double.parseDouble(scanner.nextLine());
- }
- budget -= salary;
- if(budget <= 0) {
- break;
- }
- command = scanner.nextLine();
- }
- //достатъчен или не
- if(budget >= 0) {
- System.out.printf("We are left with %.2f leva.", budget);
- } else {
- double needMoney = Math.abs(budget);
- System.out.printf("We need %.2f leva for our actors.", needMoney);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment