package fantanstic; public class NeedMoney { /** * Variables * */ private int nowAge, endAge=80; private double moneyPerDay=1000, totalMoney=moneyPerDay*endAge, needMoney; /** * Methods * */ public NeedMoney(int nowAge) { this.nowAge=nowAge; calcNeed(); } private void calcNeed(){ totalMoney=moneyPerDay*endAge*365; needMoney=(endAge-nowAge)*moneyPerDay*365; System.out.println("从你`"+nowAge+"`到`"+endAge+"`如果每天花` "+moneyPerDay); System.out.println("你还需要` "+new Double(needMoney).intValue()+" `才能天天玩."); System.out.println("照这样子算 你一辈子得花` "+new Double(totalMoney).intValue()); } public static void main(String[] args) { new NeedMoney(21); } }