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 profit = Double.parseDouble(scanner.nextLine());
- double totalSum = 0;
- String input = scanner.nextLine();
- while (!input.equals("Party!")) {
- String cocktailName = input;
- int countCocktails = Integer.parseInt(scanner.nextLine());
- int priceCocktail = cocktailName.length();
- double sumCocktails = countCocktails * priceCocktail;
- if (sumCocktails % 2 != 0) {
- sumCocktails = sumCocktails * 0.75;
- }
- totalSum = totalSum + sumCocktails;
- if (totalSum >= profit) {
- break;
- }
- input = scanner.nextLine();
- }
- double diff = Math.abs(profit - totalSum);
- if (input.equals("Party!")) {
- System.out.printf("We need %.2f leva more.%n", diff);
- } else if (totalSum >= profit) {
- System.out.println("Target acquired.");
- }
- System.out.printf("Club income - %.2f leva.", totalSum);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement