Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class P04_MovieStars {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- double budget = Double.parseDouble(scan.nextLine());
- String actorName = scan.nextLine();
- while (!"ACTION".equals(actorName)) {
- if (actorName.length() > 15) {
- budget -= budget * 0.2;
- } else {
- double salary = Double.parseDouble(scan.nextLine());
- budget -= salary;
- }
- if (budget < 0) {
- break;
- }
- actorName = scan.nextLine();
- }
- if ("ACTION".equals(actorName)) {
- System.out.println(String.format("We are left with %.2f leva.", budget));
- } else {
- System.out.println(String.format("We need %.2f leva for our actors.", Math.abs(budget)));
- }
- }
- }
Add Comment
Please, Sign In to add comment