-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVolleyPointsTracker.java
More file actions
47 lines (37 loc) · 1.89 KB
/
VolleyPointsTracker.java
File metadata and controls
47 lines (37 loc) · 1.89 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
import java.util.*;
import java.io.*;
public class VolleyPointsTracker {
public static void main (String[] args) throws IOException {
//create our buffer reader
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
//get the number of players
System.out.println("Enter Number of Players: ");
int numPlayers = Integer.parseInt(bufferedReader.readLine().trim());
for (int i=0; i<numPlayers; i++){
//get the name of the players
System.out.println("\nEnter Player Name: ");
String playerName = bufferedReader.readLine();
System.out.println("Enter service, blocks and attack attempts separeated by sapces");
String[] attempts = bufferedReader.readLine().split(" ");
int service = Integer.parseInt(attempts[0]);
int blocks = Integer.parseInt(attempts[1]);
int attacks = Integer.parseInt(attempts[2]);
System.out.println("Enter number of successful attempts separated by spaces");
String[] success = bufferedReader.readLine().split(" ");
int suc1 = Integer.parseInt(success[0]);
int suc2 = Integer.parseInt(success[1]);
int suc3 = Integer.parseInt(success[1]);
//calculate the percentage of successful attempts from the total ones
//succesful services
double sucServices = ((double) suc1 / service) * 100;
System.out.println(sucServices);
// successful blocks
double sucBlocks = ((double) suc2 / blocks) * 100;
// successful attacks
double sucAttacks = ((double) suc3 / attacks) * 100;
System.out.println("Points for service: " +sucServices+ "%");
System.out.println("Points for Blocks: " +sucBlocks+ "%");
System.out.println("Points for attacks: " +sucAttacks+ "%");
}
}
}