java利息代码 java编程计算银行利息

这串JAVA代码,我想求得所有的利息和,要怎么写先定义个sum:double sum=0;
然后在for循环中加入这代码就好了:sum=repayInterest sum;
java编写程序:要求用户输入贷款的年利率,总金额和年数,程序计算月支付金额和你也不说计算公式,不知道怎么计算,我去网上找了一个月支付款java利息代码的计算公式 , 不知道和你题目java利息代码的要求是否一样,如果不一样你就改下公式就行 。
java代码如下:
public class Loan {
public static void main(String[] args){
double rate ;//利率
int year ; //年数
double money ; //贷款总额
double monthpay ;//月付款
Scanner sc = new Scanner(System.in);
System.out.println("输入月利率:");
rate = sc.nextDouble();
System.out.println("输入年数:");
year = sc.nextInt();
System.out.println("输入贷款总额:");
money = sc.nextDouble();
//计算月付款
monthpay = (money * rate)/Math.abs(1 - (1 / (1rate ) * year * 12 ));
System.out.println("每月应该还贷款:"monthpay);
}
}
java编写程序,计算在银行存10000元一年后的金额,银行一年的定期利息是百public class Test {
public static void main(String[] args) {
double rate = 3.0 / 100; // 利息3%
double amt = 10000; // 金额 10000
int daysOfYear = 365; // 利息计算方式
int term = 365; // 存多久 365天表示一年
// 利息
double interest = (term / daysOfYear) * (amt * rate);
// 到期金额
double mamt = interestamt;
System.out.println(amt"元存银行"term"天 , 利息是:"interest" , 到期金额是:"mamt" 。");
}
}
跪求JAVA编写的银行利息计算器代码这个很简单,只是java利息代码我对这些计算规则不熟悉
import java.util.ListIterator;
import java.util.Stack;
public class CalStr {
private String src;
/**
* constructor
*
* @param srcthe string(expression) to calculate
*/
public CalStr(String src) {
this.src = https://www.04ip.com/post/src;
}
/**
* calculate to get the result
*
* @return(double)result
*/
public double getResult() {
String postfix = getPostfix();
Stack stk = new Stack();
// System.out.println(postfix);
String parts[] = postfix.split("");
double result = 0;
for (int i = 0; iparts.length; i) {
char tmp = parts[i].charAt(0);
if (!isOperator(tmp)) {
stk.push(parts[i]);
} else {
double a = Double.parseDouble((String) stk.pop());
double b = Double.parseDouble((String) stk.pop());
// b is followed by a in the orignal expression
result = calculate(b, a, tmp);
stk.push(String.valueOf(result));
}
}
return result;
}
/**
* test if the character is an operator,such,-,*,/
*
* @param opthe character to test
* @returntrue if op is an operator otherwise false
*/
private boolean isOperator(char op) {
return (op == ' ' || op == '-' || op == '*' || op == '/');
}
/**
* calculate an expression such (a op b)
*
* @param anumber 1
* @param bnumber 2
* @param opthe operator
* @return(double)(a op b)
*/
public double calculate(double a, double b, char op) {
switch (op) {
case ' ':
return ab;
case '-':
return a - b;
case '*':
return a * b;
case '/':
return a / b;
}
return -1;
}
/**
* convert the suffix to postfix
*
* @returnthe postfix as a string
*/
private String getPostfix() {
Stack stk = new Stack();
String postfix = new String();
char op;
int i = 0;
while (isrc.length()) {
if (Character.isDigit(src.charAt(i)) || src.charAt(i) == '.') {
postfix= " ";
do {
postfix= src.charAt(i);
} while ((isrc.length())
(Character.isDigit(src.charAt(i))));
postfix= " ";
}
else {
switch (op = src.charAt(i)) {
case '(':
stk.push("(");
break;
case ')':
while (stk.peek() != "(") {
String tmp = (String) stk.pop();
postfix= tmp;
if (tmp.length() == 1isOperator(tmp.charAt(0)))
postfix= " ";
}
stk.pop();
postfix= " ";
break;
case ' ':
case '-':
while ((!stk.empty())(stk.peek() != "(")) {
postfix= stk.pop()" ";
}
stk.push(String.valueOf(new Character(op)));
break;
case '*':
case '/':
while ((!stk.empty())
((stk.peek() == "*") || (stk.peek() == "/"))) {
postfix= stk.pop()" ";
}
stk.push(String.valueOf(new Character(op)));
break;
}
}
}
ListIterator it = stk.listIterator(stk.size());
while (it.hasPrevious())
postfix= it.previous()" ";
return postfix.trim().replaceAll("\\.", ".");
}
/**
* main function
*
* @param args
*/
public static void main(String args[]) {
System.out.println(new CalStr("((1.5 6.000)*9 9.36)*(8 9-8*8 8*7)")
.getResult());
}
}
new CalStr( 写上java利息代码你java利息代码的计算公式 );
JAVA计算存款利息/**
需求java利息代码:本金1万元人民币java利息代码,以一年期整存整取java利息代码的形式储蓄在银行java利息代码,一年期利率为2.79%,n年后连本带息共计多少钱 。
*/
class Calculate
{
public double calcuTotal(double prin,double rate,int n) //参数分别是本金、利率,存放期
{
double inte=0.00;//利息
double sum=prin;
for(int i=0;in;i)
{
inte=inte prin*rate; //一年期整存整存的利息算法
}
sum =inte;
return sum;
}
}
class ParamSet
{
public static void main(String[] args)
{
//设置你要的参数
double prin=10000.00;
double rate=0.0279;
int n=10;
//存多少年
Calculate c = new Calculate();
double sum=c.calcuTotal(prin,rate,n);
System.out.println("本金:" prin " 元 \n存款利率:" rate '\n' n "年后连本带息共为:" sum "元");
}
}
java 计算存款利息money(1 rate)^year - money
是money * (1 rate)^year - moneyjava利息代码,和普通java利息代码的数学顺序一样java利息代码,先计算级别高的java利息代码 , 括号内的1 rate、再乘方year、再乘 money,最后减money 。
转成java的计算式,也是按顺序的,乘方的地方就是按JAVA的函数pow的要求,写进参数 。
money*Math.pow((1 rate),year)-money;
【java利息代码 java编程计算银行利息】java利息代码的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于java编程计算银行利息、java利息代码的信息别忘了在本站进行查找喔 。

    推荐阅读