Valantina

MovieStars

Jun 18th, 2019
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.92 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class P04_MovieStars {
  4.     public static void main(String[] args) {
  5.         Scanner scan = new Scanner(System.in);
  6.  
  7.         double budget = Double.parseDouble(scan.nextLine());
  8.  
  9.         String actorName = scan.nextLine();
  10.  
  11.         while (!"ACTION".equals(actorName)) {
  12.  
  13.             if (actorName.length() > 15) {
  14.                 budget -= budget * 0.2;
  15.             } else {
  16.                 double salary = Double.parseDouble(scan.nextLine());
  17.                 budget -= salary;
  18.             }
  19.  
  20.             if (budget < 0) {
  21.                 break;
  22.             }
  23.  
  24.             actorName = scan.nextLine();
  25.         }
  26.  
  27.         if ("ACTION".equals(actorName)) {
  28.             System.out.println(String.format("We are left with %.2f leva.", budget));
  29.         } else {
  30.             System.out.println(String.format("We need %.2f leva for our actors.", Math.abs(budget)));
  31.         }
  32.     }
  33. }
Add Comment
Please, Sign In to add comment