自学后第一次做小模块; package jisuanqi; import java.awt.*; import java.text.DecimalFormat; import java.util.Date; import java.util.Scanner; public class shuju1 { public static void main(String[] args)throws AWTException {//把robot的异常抛出 double A = GG(); Robot AA = new Robot();//robot类可以使用延迟 double i = 0; double MM = 0; double i2 = 0; double i3 = 0; for (;;) { for (i2 = 0; i2 < 3600; i2++) { for (int i1 = 0; i1 < 1; i1++) { Date hh = new Date();//获取当前时间 AA.delay(1000); MM = MM + A; DecimalFormat dt = new DecimalFormat("0.####");//控制doule长整形的小数点位数 System.out.println(hh + "你赚取:" + dt.format(MM) + "元"); } } System.out.println("一个小时过去了"); } } public static double GG() { Scanner B=new Scanner(System.in);//scanner键盘输入的意思; System.out.println("欢迎使用工资计算器"); System.out.println("请输入您每个月的工资;"); System.out.println(); int K=B.nextInt(); double h =K; double g = (30*(24 * 60 * 60)); double j = h / (double) g;//强制转g为double形 return j; } }