Java的。。直接copy运行就行,哈哈哈
自己的目标是过30岁生日的时候加上股票资产能达到100w。。
实际能达到50w就知足了😁
class Main { //当前时间 int year = 2021; int month = 10; //无风险月利率 double RATE = 1.0017; //起始存款 double totalMoney = 0; //起始每月存款 int salary = 999; //上个月利息 double interest = 0; //每个月存的钱 int money = 0; //起始公积金总额 int totalHouse = 0; //起始每个月公积金 int house = 999; //总资产 double asset = 0; public static void main (String[] args) { Scanner input = new Scanner(System.in); System.out.System.out.println("输入截至时间,格式为yyyy-mm:"); String[] time = input.nextLine().split("-"); int endYear = Integer.parseInt(time[0]); int endMonth = Integer.parseInt(time[1]); System.out.System.out.println("输入转正时间和转正后每月存款,格式为yyyy-mm-money:"); time = input.nextLine().split("-"); int fullYear = Integer.parseInt(time[0]); int fullMonth = Integer.parseInt(time[1]); int fullSalary = Integer.parseInt(time[2]); System.out.System.out.println("输入发年终奖时间和当月追加存款,格式为yyyy-mm-money:"); time = input.nextLine().split("-"); int bonusYear = Integer.parseInt(time[0]); int bonusMonth = Integer.parseInt(time[1]); int bonusMoney = Integer.parseInt(time[2]); System.out.System.out.println("输入全额公积金时间和金额,格式为yyyy-mm-money:"); time = input.nextLine().split("-"); int houseYear = Integer.parseInt(time[0]); int houseMonth = Integer.parseInt(time[1]); int fullHouse = Integer.parseInt(time[2]); new test().asset(endYear, endMonth, fullYear, fullMonth, fullSalary, bonusYear, bonusMonth, bonusMoney, houseYear, houseMonth, fullHouse); } public void asset(int endYear, int endMonth, int fullYear, int fullMonth, int fullSalary, int bonusYear, int bonusMonth, int bonusMoney, int houseYear, int houseMonth, int fullHouse){ //是否是发年终奖的月份 boolean bonus = isBonusTime(bonusYear, bonusMonth); money = bonus ? salary+bonusMoney : salary; totalMoney = totalMoney * RATE + money; totalHouse = totalHouse + house; interest = totalMoney * (RATE - 1); asset = totalMoney + totalHouse; System.out.println(year + "年" + month + "月" + "\t存入:" + money + "\t上月利息:" + String.format("%.0f", interest) + "\t总存款:" + String.format("%.0f", totalMoney) + "\t公积金:" + totalHouse + "\t总资产:" + String.format("%.0f", asset) ); //结束循环 if (year == endYear && month == endMonth) { break; } if (month == 12) { year++; month = 0; } if (year == fullYear && month == fullMonth) { salary = fullSalary; } if (year == houseYear && month == houseMonth) { house = fullHouse; } } private boolean isBonusTime(int bonusYear, int bonusMonth) { return (year >= bonusYear) && (month == bonusMonth); } }
全部评论
(2) 回帖