-
Notifications
You must be signed in to change notification settings - Fork 6
/
Ludo King.java
45 lines (39 loc) · 871 Bytes
/
Ludo King.java
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
//Ludo King
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter Alex points");
int pa=sc.nextInt();
if (pa<0 || pa>50){
System.out.println(pa+" is an invalid number");
System.exit(1);
}
System.out.println("Enter Nikil points");
int pn=sc.nextInt();
if(pn<0 || pn>50){
System.out.println(pn+" is an invalid number");
System.exit(1);
}
System.out.println("Enter Sam points");
int ps=sc.nextInt();
if(ps<0 || ps>50){
System.out.println(ps+" is an invalid number");
System.exit(1);
}
if(pa>pn && pa>ps){
System.out.println("Alex scored "+pa+" points and won the
game");
}
else if (pn>pa && pn>ps){
System.out.println("Nikil scored "+pn+" points and won the
game");
}
else{
System.out.println("Sam scored "+ps+" points and won the
game");
}
}
}