Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double neededSum = Double.parseDouble(scanner.nextLine()),
- currentSum, income = 0;
- int cocktailCount;
- String cocktailName;
- while (income < neededSum && !(cocktailName = scanner.nextLine()).equals("Party!")) {
- cocktailCount = Integer.parseInt(scanner.nextLine());
- currentSum = cocktailCount * cocktailName.length();
- if ((int) currentSum % 2 == 1) {
- currentSum *= 0.75;
- }
- income += currentSum;
- }
- if (neededSum > income) {
- System.out.printf("We need %.2f leva more.\n", neededSum - income);
- } else {
- System.out.println("Target acquired.");
- }
- System.out.printf("Club income - %.2f leva.\n", income);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement