Advertisement
Deiancom

Club

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