一、println的使用
拼接输出:System.out.println("a的值为" + a);
二、基本算术运算实现
package daytwo;
public class operations {
public static void main(String[] args) {
int intnumberone,intnumbertwo,intnumberresult;
double doublenumberone,doublenumbertwo,doublenumberresult;
intnumberone=15;
intnumbertwo=4;
doublenumberone=1.2;
doublenumbertwo=3.5;
//addition
intnumberresult=intnumberone+intnumbertwo;
doublenumberresult=doublenumberone+doublenumbertwo;
System.out.println(""+intnumberone+"+"+intnumbertwo+"="+intnumberresult);
System.out.println(""+doublenumberone+"+"+doublenumbertwo+"="+doublenumberresult);
//subtraction
intnumberresult=intnumberone-intnumbertwo;
doublenumberresult=doublenumberone-doublenumbertwo;
System.out.println(""+intnumberone+"-"+intnumbertwo+"="+intnumberresult);
System.out.println(""+doublenumberone+"-"+doublenumbertwo+"="+doublenumberresult);
//multiplication
intnumberresult=intnumberone*intnumbertwo;
doublenumberresult=doublenumberone*doublenumbertwo;
System.out.println(""+intnumberone+"*"+intnumbertwo+"="+intnumberresult);
System.out.println(""+doublenumberone+"*"+doublenumbertwo+"="+doublenumberresult);
//division
intnumberresult=intnumberone/intnumbertwo;
doublenumberresult=doublenumberone/doublenumbertwo;
System.out.println(""+intnumberone+"/"+intnumbertwo+"="+intnumberresult);
System.out.println(""+doublenumberone+"/"+doublenumbertwo+"="+doublenumberresult);
//modulus
intnumberresult=intnumberone%intnumbertwo;
System.out.println(""+intnumberone+"%"+intnumbertwo+"="+intnumberresult);
}//of main
}//of class
三、运行结果