用java编写模拟计算银行整存整取存款利息,1建立bank为抽象类,其中有两个抽象方法,计算存款

2022-03-30 财经 184阅读
publicabstractclassbank{


publicabstractdoublegetTotal(doublemoney,intyears,doubleinterest);
}

publicclassgeneralBankextendsbank{

publicdoublegetTotal(doublemoney,intyears,doubleinterest){
doubletotal=money*years*(interest)+money;
//将double类型转化为decimal防止double运算精度显示错误
java.text.DecimalFormatdecimalFormat=newjava.text.DecimalFormat("0.00");
total=Double.parseDouble(decimalFormat.format(total));
returntotal;
}

}

publicclasstest{

publicstaticvoidmain(String[]args){
bankbank=newgeneralBank();
doubletotal=bank.getTotal(10000,1,0.03);
System.out.println(total);
}

}
声明:你问我答网所有作品(图文、音视频)均由用户自行上传分享,仅供网友学习交流。若您的权利被侵害,请联系fangmu6661024@163.com