我是靠谱客的博主 谨慎歌曲,最近开发中收集的这篇文章主要介绍Java 银行计算利息,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

package package2;
public class Bank {
int saveMoney;
int year;
double interest;
double interestRate=0.29;
public double computerInterest(){
interest=year*interestRate*saveMoney;
return interest;
}
public void setInterestRate(double rate){
interestRate=rate;
}
}
package package2;
public class ConstructionbBank extends Bank{
double year;
public double computerInterest(){
super.year=(int)year;
double r=year-(int)year;
int day=(int)(r*1000);
double yearInterest=super.computerInterest();
double dayInterest=day*0.0001*saveMoney;
interest=yearInterest+dayInterest;
System.out.printf("%d元存在建设银行%d年零%d天的利息:%f元n",saveMoney,super.year,day,interest);
return interest;
}
}
package package2;
public class BankOfDalian extends Bank{
double year;
public double computerInterest(){
super.year=(int)year;
double r=year-(int)year;
int day=(int)(r*1000);
double yearInterest=super.computerInterest();
double dayInterest=day*0.00012*saveMoney;
interest=yearInterest+dayInterest;
System.out.printf("%d元存在建设银行%d年零%d天的利息:%f元n",saveMoney,super.year,day,interest);
return interest;
}
}
package package2;
public class SaveMoney {
public static void main(String[] args) {
int amount=8000;
ConstructionbBank bank1=new ConstructionbBank();
bank1.saveMoney=amount;
bank1.year=8.236;
bank1.setInterestRate(0.035);
double interest1=bank1.computerInterest();
BankOfDalian bank2=new BankOfDalian();
bank2.saveMoney=amount;
bank2.year=8.236;
bank2.setInterestRate(0.035);
double interest2=bank2.computerInterest();
System.out.printf("两个银行利息相差%f元n",interest2-interest1);
}
}

最后

以上就是谨慎歌曲为你收集整理的Java 银行计算利息的全部内容,希望文章能够帮你解决Java 银行计算利息所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(42)

评论列表共有 0 条评论

立即
投稿
返回
顶部