java语言基础案例
象棋口诀
输出
package nb;
public class XiangQi {
public static void main(String[] args) {
char a = '马';
char b = '象';
char c = '卒';
System.out.println(a+"走日"+b+"走田"+"小"+c+"一去不复还");
}
}
输出汇款单
package nb;
import java.text.SimpleDateFormat;
import java.util.Date;
public class XinXi {
public static void main(String[] args) {
System.out.println("\t\t中国工商银行");
System.out.println("-----------------------");
Date date=new Date();
SimpleDateFormat dateFormat=new SimpleDateFormat("YYYY-MM-dd");
System.out.format("日期:\t\t%s",dateFormat.format(date));
System.out.format("\n户名:\t\t%s","张三");
System.out.format("\n账号:\t\t%d",123456789);
System.out.format("\n币种:\t\t%s","RMB");
System.out.format("\n存款金额:\t\t%.1f",10000.0);
System.out.format("\n存款序号:\t\t%d",010);
System.out.format("\n柜员号:\t\t%d",12345);
System.out.println("\n-----------------------");
}
}
计算月收入
工资4500,奖金1000,缴纳五险500,计算最终收入
package nb;
public class ShouRu {
public static void main(String[] args) {
System.out.printf("%d",4500+1000-500);
}
}