-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphrase.java
More file actions
53 lines (33 loc) · 1.1 KB
/
phrase.java
File metadata and controls
53 lines (33 loc) · 1.1 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
48
49
50
51
52
53
import java.util.Scanner;
import java.util.Random;
public class phrase{
public static void main(String []args){
//the random number generator with no duplicated
Random random=new Random();
int[]a=new int[5];
int number;
for (int i=0; i<a.length; i++){
a[i]=random.nextInt(5);
for(int j=0; j<i;j++){
if(a[i]==a[j]){
i--;
break;
}//if
}//for2
}//for1
String ans,ques;
String [] p={"under the weather", "hit the sack", "break a leg", "call it a day", "better late than never"};//p stands for problems
String [] h={"sick", "take a nap", "good luck", "finish a work", "doing it is better than not doing it at all"};
System.out.println("This is a game that helps you with your English phrases.");
Scanner str = new Scanner(System.in);
for (int i=0;i<5;i++){
String q=p[a[i]];//using q to replace p[a[i]]
String d=h[a[i]];//using d to replace h[a[i]]
System.out.println(i+"."+"The meaning of the phrase is "+ d+"."+" The first character and the last one is "+q.charAt(0)+"..."+q.charAt(q.length()-1));
ans=str.nextLine();
if(ans.equals(q)){
System.out.println("Congrats!");
}
}//for i
}//main
}//class