Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Club4 {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- double wantedMoney = Double.parseDouble(scan.nextLine());
- double sumPrice = 0;
- String name = scan.nextLine();
- while (!name.equals("Party!")) {
- int number = Integer.parseInt(scan.nextLine());
- double cena = name.length();
- double sum = cena * number;
- if ((sumPrice % 10 ) % 2 == 1) {
- sumPrice = sumPrice * 0.75;
- }
- sumPrice += sum;
- if (sumPrice >= wantedMoney) {
- System.out.println("Target acquired.");
- break;
- }
- name = scan.nextLine();
- }
- if (name.equals("Party!")) {
- double diff = wantedMoney - sumPrice;
- System.out.printf("We need %.2f leva more.%n", diff);
- }
- System.out.printf("Club income - %.2f leva.", sumPrice);
- }
- }
Add Comment
Please, Sign In to add comment