-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest2.java
More file actions
27 lines (20 loc) · 859 Bytes
/
Test2.java
File metadata and controls
27 lines (20 loc) · 859 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
package nameyu;
import java.util.Scanner;
public class Test2 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
double wide=(Math.random()*101+(-50));
//int 改成double之后,(50,51)和(-51,-50)这两个不符合题意的取值范围内的数字就有可能出现,
double high=(Math.random()*201+(-100));
//所以我加了个while来规避两种情况
while (wide>50|wide<(-50)|high>100|high<(-100)){
wide=(Math.random()*101+(-50));
high=(Math.random()*201+(-100));
}
Scanner input=new Scanner(System.in);
System.out.println("The coordinate is " + "(" + wide + "," + high + ")");
}
}