1.写出下列代码的输出:
float f=23.89F;
int a-(int)f;
System.out. println(“f-”+f);
System, out. printIn(“a="ta);
2.对于下列代码,当x= 2,y= 3 时输出是什么;当x= 3,y= 2 时输出是什么;当x= 3,y= 3 时输
出是什么。
if(x> 2)
if (y〉2)(
int z =x + y:
System. out. println(“z=“+ x);
else
System. out. printIn(“* =“+ x);
代码不要这么黏贴,全是错。结果如下
代码,不知道是不是你要的样子,但是我已经尽力修正了
public static void main(String[] args) {
float f = 23.89F;
int a = (int) f;
System.out.println("f=" + f);
System.out.println("a=" + a);
int x = 2;
int y = 3;
if (x > 2) {
if (y > 2) {
int z = x + y;
System.out.println("z=" + x);
}
} else
System.out.println("* =" + x);
x = 3;
y = 2;
if (x > 2) {
if (y > 2) {
int z = x + y;
System.out.println("z=" + x);
}
} else
System.out.println("* =" + x);
x = 3;
y = 3;
if (x > 2) {
if (y > 2) {
int z = x + y;
System.out.println("z=" + x);
}
} else
System.out.println("* =" + x);
}
先把代码照着敲对了再说
输出个错误!