Lyubohd

05. Club

Oct 24th, 2020 (edited)
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.03 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.     public static void main(String[] args) {
  5.         Scanner scan = new Scanner(System.in);
  6.         double clubTarget = Double.parseDouble(scan.nextLine());
  7.         double moneyEarned = 0.0;
  8.  
  9.         String input = scan.nextLine();
  10.         while (!"Party!".equals(input)) {
  11.             int count = Integer.parseInt(scan.nextLine());
  12.  
  13.             double price = input.length() * count;
  14.             if (price % 2 != 0) {
  15.                 price = price * 0.75;
  16.             }
  17.             moneyEarned = moneyEarned + price;
  18.             if (moneyEarned >= clubTarget) {
  19.                 break;
  20.             }
  21.  
  22.             input = scan.nextLine();
  23.         }
  24.  
  25.         if ("Party!".equals(input)) {
  26.             double moneyNeed = clubTarget - moneyEarned;
  27.             System.out.printf("We need %.2f leva more.%n", moneyNeed);
  28.         } else {
  29.             System.out.println("Target acquired.");
  30.         }
  31.  
  32.         System.out.printf("Club income - %.2f leva.", moneyEarned);
  33.     }
  34. }
Add Comment
Please, Sign In to add comment