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 scan = new Scanner(System.in);
- double clubTarget = Double.parseDouble(scan.nextLine());
- double moneyEarned = 0.0;
- String input = scan.nextLine();
- while (!"Party!".equals(input)) {
- int count = Integer.parseInt(scan.nextLine());
- double price = input.length() * count;
- if (price % 2 != 0) {
- price = price * 0.75;
- }
- moneyEarned = moneyEarned + price;
- if (moneyEarned >= clubTarget) {
- break;
- }
- input = scan.nextLine();
- }
- if ("Party!".equals(input)) {
- double moneyNeed = clubTarget - moneyEarned;
- System.out.printf("We need %.2f leva more.%n", moneyNeed);
- } else {
- System.out.println("Target acquired.");
- }
- System.out.printf("Club income - %.2f leva.", moneyEarned);
- }
- }
Add Comment
Please, Sign In to add comment