package JavaDay2;
import java.util.Random;
public class Program4 {
public static void main(String[] args) {
Random r=new Random();//产生随机数
int x=50+r.nextInt(150);//获取50到200之间的随机数
if(x%2!=0)//判断获取的随机数x为奇数的方法
System.out.println("x为奇数"+x+"的平方根约等于"+(float)Math.sqrt(x));
else
System.out.println("x为偶数时"+x+"的平方为"+x*x);
}
import java.util.Random;
public class Program4 {
public static void main(String[] args) {
Random r=new Random();//产生随机数
int x=50+r.nextInt(150);//获取50到200之间的随机数
if(x%2!=0)//判断获取的随机数x为奇数的方法
System.out.println("x为奇数"+x+"的平方根约等于"+(float)Math.sqrt(x));
else
System.out.println("x为偶数时"+x+"的平方为"+x*x);
}
}