用java编写程序:求银行本息的!题目如下:
存期有一年,两年,三年,五年年利率分别为2.252.73.243.6现存入银行银行10000元,到期取款,银行应支付的本息分别为多少.(利息=本金*年利率*存期本息=本金...
存期有一年,两年,三年,五年
年利率分别为2.25 2.7 3.24 3.6
现存入银行银行10000元,到期取款,银行应支付的本息分别为多少.
(利息 =本金*年利率*存期
本息=本金+利息) 展开
年利率分别为2.25 2.7 3.24 3.6
现存入银行银行10000元,到期取款,银行应支付的本息分别为多少.
(利息 =本金*年利率*存期
本息=本金+利息) 展开
3个回答
推荐于2017-12-16
展开全部
简单些了个,如果没理解错的话,应该可以满足要求:
public class Benxi{
private double benxi;//本息
private double lilu;//年利率
//计算本息
private double resBenxi(double money,int year){
benxi=money+money*getLilu(year)*year;
return benxi;
}
//选择利率
private double getLilu(int year){
switch(year){
case 1:
lilu=2.25/100;
break;
case 2:
lilu=2.7/100;
break;
case 3:
lilu=3.24/100;
break;
case 5:
lilu=3.6/100;
break;
}
return lilu;
}
public static void main(String[] args){
Benxi bx=new Benxi();
System.out.println("10000元存一年的本息为:"+bx.resBenxi(10000,1));
System.out.println("10000元存两年的本息为:"+bx.resBenxi(10000,2));
System.out.println("10000元存三年的本息为:"+bx.resBenxi(10000,3));
System.out.println("10000元存五年的本息为:"+bx.resBenxi(10000,5));
}
}
public class Benxi{
private double benxi;//本息
private double lilu;//年利率
//计算本息
private double resBenxi(double money,int year){
benxi=money+money*getLilu(year)*year;
return benxi;
}
//选择利率
private double getLilu(int year){
switch(year){
case 1:
lilu=2.25/100;
break;
case 2:
lilu=2.7/100;
break;
case 3:
lilu=3.24/100;
break;
case 5:
lilu=3.6/100;
break;
}
return lilu;
}
public static void main(String[] args){
Benxi bx=new Benxi();
System.out.println("10000元存一年的本息为:"+bx.resBenxi(10000,1));
System.out.println("10000元存两年的本息为:"+bx.resBenxi(10000,2));
System.out.println("10000元存三年的本息为:"+bx.resBenxi(10000,3));
System.out.println("10000元存五年的本息为:"+bx.resBenxi(10000,5));
}
}
2013-12-31
展开全部
import java.util.Scanner;
public class Bank{
public static void main(String args[]){
double increase[]={0.0225,0.027,0.0324,0,0.036};
double money, interest;
int years;
Scanner scan=new Scanner(System.in);
System.out.print("请输入要存入的金额:");
money=scan.nextDouble();
System.out.print("请输入要存的年限:");
years=scan.nextInt();
interest=money*increase[years-1]*years;
money+=interest;
System.out.println("利息:"+interest);
System.out.println("本息:"+money);
}
}
public class Bank{
public static void main(String args[]){
double increase[]={0.0225,0.027,0.0324,0,0.036};
double money, interest;
int years;
Scanner scan=new Scanner(System.in);
System.out.print("请输入要存入的金额:");
money=scan.nextDouble();
System.out.print("请输入要存的年限:");
years=scan.nextInt();
interest=money*increase[years-1]*years;
money+=interest;
System.out.println("利息:"+interest);
System.out.println("本息:"+money);
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2018-06-12
展开全部
import java.util.Scanner;
/**
*
* @author 命运里的路人
* @version $Id: Banking.java, v 0.1 2018年6月12日 下午4:06:09 命运里的路人 Exp $
*/
public class Banking {
/**创建一个静态的数组,将利率存入 */
private static double[] rates = new double[] { 2.25, 2.7, 3.24, 3.24, 3.6 };
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("请输入存入金额");
double price = scan.nextDouble();
scan.nextLine();
System.out.println("请输入存入年限");
int year = scan.nextInt();
double rate = rates[year - 1];//将利率取出来
System.out.println("本息和=" + (price * (rate / 100) * year + price));
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询