编写一个的JAVA程序,求完整代码

定义a,b,d…h8个变量并赋值,要求涉及8个基本数据类型,打印输出8个变量值以及x和y的值(x=(a%b),y=(c+d)),判断b和c是否相等,并打印输出;

public class Demo3 {

public static void main(String[] args) {

byte a =1;
short b=1;
int c = 1;
long d = 1l;
float e=1f;
double f =1;
char g ='1';
boolean h = true;
System.out.println("byte a ="+a);
System.out.println("short b="+b);
System.out.println("int c ="+c);
System.out.println("long d ="+d);
System.out.println("float e="+e);
System.out.println("double f ="+f);
System.out.println("char g ="+g);
System.out.println("boolean h ="+h);

int x=a%b;
long y = c+d;
boolean z=(b==c);
System.out.println("int x="+x);
System.out.println("long y"+y);
System.out.println("boolean z"+z);

}
}
温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答