-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanswer5.txt
More file actions
33 lines (33 loc) · 1004 Bytes
/
answer5.txt
File metadata and controls
33 lines (33 loc) · 1004 Bytes
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
import java.util.Scanner();
Scanner input = new Scanner(System.in);
System.out.println("Guess the year (between 1990 and 2017):");
int year = input.nextInt();
System.out.println("Guess the month (as a number):";
int month = input.nextInt();
System.out.println("Guess the day (as a number):";
int day = input.nextInt();
int randomYear = 1990+(int)(Math.random()*(2017-1990+1));
int randomMonth =1+(int)(Math.random()*12);
int randomDay = 1+(int)(Math.random()*30);
String s = "null";
if(year==randomYear){
if(month==randomMonth{
if(day==randomDay{
String s = "You got it, wow!";
}else{
if(day<randomDay)
s= "You were too early";
else
s="You were too late";}
}else{
if(month<randomMonth)
s="You were too early";
else
s="You were too late";}
}else{
if(year<randomYear)
s="You were too early";
else
s="You were too late";}
System.out.println("The correct date was " + year + "-" + month + "-" + day + ".");
System.out.println(s);