Advertisement
Spocoman

Club

Sep 3rd, 2024
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.94 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         double neededSum = Double.parseDouble(scanner.nextLine()),
  7.                 currentSum, income = 0;
  8.         int cocktailCount;
  9.  
  10.         String cocktailName;
  11.         while (income < neededSum && !(cocktailName = scanner.nextLine()).equals("Party!")) {
  12.             cocktailCount = Integer.parseInt(scanner.nextLine());
  13.             currentSum = cocktailCount * cocktailName.length();
  14.             if ((int) currentSum % 2 == 1) {
  15.                 currentSum *= 0.75;
  16.             }
  17.             income += currentSum;
  18.         }
  19.  
  20.         if (neededSum > income) {
  21.             System.out.printf("We need %.2f leva more.\n", neededSum - income);
  22.         } else {
  23.             System.out.println("Target acquired.");
  24.         }
  25.         System.out.printf("Club income - %.2f leva.\n", income);
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement