Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class P04_Club {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- double target = Double.parseDouble(scan.nextLine());
- String cocktail = scan.nextLine();
- double income = 0.0;
- while (!"Party!".equals(cocktail)) {
- int quantity = Integer.parseInt(scan.nextLine());
- int price = quantity * cocktail.length();
- double finalPrice = price;
- if (price % 2 != 0) {
- finalPrice *= 0.75;
- }
- income += finalPrice;
- target -= finalPrice;
- if (target <= 0) {
- break;
- }
- cocktail = scan.nextLine();
- }
- if ("Party!".equals(cocktail)) {
- System.out.println(String.format("We need %.2f leva more.", target));
- } else {
- System.out.println("Target acquired.");
- }
- System.out.println(String.format("Club income - %.2f leva.", income));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement