5. 假设银行(Bank)按整年year(只能取正整数)计算利息,利息计算公式为: interest=year*0.35*savedMoney ,其中savedMoney 为存款 中国建设银行(

package Ch5;
public class BankSucceed {
public static void main(String[] args) {
Construction_Bank cb=new Construction_Bank(100000,3);
System.out.println("得到的本息共:"+cb.get_allMoney());
}
}


class Bank{
protected int savedMoney;
protected int year;
private final Double s=0.35;

Bank(){

}

Bank(int savedMoney,int year){
this.savedMoney=savedMoney;
this.year=year;
}



public double get_allMoney() {
return year*0.35*savedMoney;
}
}


class Construction_Bank extends Bank{

public Construction_Bank() {
super();
}
public Construction_Bank(int savedMoney,int year) {
super(savedMoney,year);
}
public double get_allMoney() {
return ((int)year*0.35*savedMoney)+(((year-(int)year)/(1.0/365))*0.001);
}
}

你可能感兴趣的:(5. 假设银行(Bank)按整年year(只能取正整数)计算利息,利息计算公式为: interest=year*0.35*savedMoney ,其中savedMoney 为存款 中国建设银行()