-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClub.java
More file actions
54 lines (32 loc) · 1.12 KB
/
Copy pathClub.java
File metadata and controls
54 lines (32 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package PBExams;
import java.util.Scanner;
public class Club {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
double profit = Double.parseDouble(scanner.nextLine());
String name = scanner.nextLine();
double totalPrice = 0;
boolean flag = false;
while (!name.equals("Party!")){
double priceCoctail = 0;
int quantity = Integer.parseInt(scanner.nextLine());
int length = name.length();
priceCoctail = quantity * length;
if(priceCoctail % 2 == 1){
priceCoctail = priceCoctail - priceCoctail * 0.25;
}
totalPrice = totalPrice + priceCoctail;
if(totalPrice >= profit){
flag = true;
break;
}
name = scanner.nextLine();
}
if(flag){
System.out.println("Target acquired.");
}else {
System.out.printf("We need %.2f leva more.%n",profit - totalPrice);
}
System.out.printf("Club income - %.2f leva.",totalPrice);
}
}