-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcode 68.txt
69 lines (48 loc) · 1.6 KB
/
code 68.txt
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
Program: 2017 Past Paper - Practical
Programmer: J.Sookha
Description:
*/
package tennisplayers;
import java.util.Scanner;
public class TennisPlayers{
static int intCount1, intCount2, intCount3;
static int intMatchCount;
static int intWhichPlayer;
public static void main(String[] args){
// reading in value
// increment counters
// print when done
Scanner sc = new Scanner(System.in);
intCount1 = 0;
intCount2 = 0;
intCount3 = 0;
intMatchCount = 1;
String strDisplayQuestion;
strDisplayQuestion = "Please enter a 1, 2 or 3 for the winning player: \n" +
"(1) Novak Djokovic \n" +
"(2) Andy Murray \n" +
"(3) Roger Federer \n";
System.out.println(strDisplayQuestion);
System.out.println("Enter the player who won match " + intMatchCount + ":");
intWhichPlayer = sc.nextInt();
while(intWhichPlayer != 0){
if (intWhichPlayer == 1)
intCount1 = intCount1 + 1;
if (intWhichPlayer == 2)
intCount2 = intCount2 + 1;
if (intWhichPlayer == 3)
intCount3 = intCount3 + 1;
intMatchCount = intMatchCount + 1;
System.out.println("Enter the player who won match " + intMatchCount + ":");
intWhichPlayer = sc.nextInt();
}
String strAnswer;
strAnswer = "NOVAK DJOKOVIC: \t" + intCount1 + "\n" +
"ANDY MURRAY: \t" + intCount2 + "\n" +
"ROGER FEDERER: \t" + intCount3 + "\n" +
"---------------------------------------- \n" +
"GAME COUNT: " + intMatchCount;
System.out.println(strAnswer);
}
}