-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBasketballTournament.java
More file actions
46 lines (31 loc) · 1.26 KB
/
Copy pathBasketballTournament.java
File metadata and controls
46 lines (31 loc) · 1.26 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
package PBExams;
import java.util.Scanner;
public class BasketballTournament {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String name = scanner.nextLine();
int total = 0;
int win = 0;
int lost = 0;
while(!name.equals("End of tournaments")){
int games = Integer.parseInt(scanner.nextLine());
int counter = 0;
for (int i = 1; i <= games ; i++) {
int pointsDesi = Integer.parseInt(scanner.nextLine());
int points = Integer.parseInt(scanner.nextLine());
counter ++;
if(pointsDesi > points){
System.out.printf("Game %d of tournament %s: win with %d points.%n",counter,name,pointsDesi - points);
win ++;
}else {
System.out.printf("Game %d of tournament %s: lost with %d points.%n",counter,name,points - pointsDesi);
lost ++;
}
total ++;
}
name = scanner.nextLine();
}
System.out.printf("%.2f%% matches win%n", (win * 1.00 / total)* 100);
System.out.printf("%.2f%% matches lost", (lost * 1.00/ total) * 100);
}
}