Advertisement
veronikaaa86

04. Movie Stars

Apr 22nd, 2023
699
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.00 KB | None | 0 0
  1. package examPrep;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class P05MovieStars {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         double budget = Double.parseDouble(scanner.nextLine());
  10.  
  11.         String input = scanner.nextLine();
  12.         while (!input.equals("ACTION")) {
  13.             String actorName = input;
  14.             int nameLength = actorName.length();
  15.  
  16.             double salary = 0;
  17.             if (nameLength <= 15) {
  18.                 salary = Double.parseDouble(scanner.nextLine());
  19.             } else {
  20.                 salary = budget * 0.2;
  21.             }
  22.  
  23.             budget = budget - salary;
  24.  
  25.             if (budget < 0) {
  26.                 break;
  27.             }
  28.  
  29.             input = scanner.nextLine();
  30.         }
  31.  
  32.         if (budget < 0) {
  33.             System.out.printf("We need %.2f leva for our actors.", Math.abs(budget));
  34.         } else {
  35.             System.out.printf("We are left with %.2f leva.", budget);
  36.         }
  37.     }
  38. }
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement