求大神用eclipse java 编写一个程序,全分送上,急求,谢谢了
来源:学生作业帮 编辑:神马作文网作业帮 分类:综合作业 时间:2024/11/11 09:35:27
求大神用eclipse java 编写一个程序,全分送上,急求,谢谢了
The program should prompt for and accept three values from the user:
· the initial deposit amount (a double value representing the deposit value in dollars)
· the rate of interest earned per annum (yearly) on the account balance (a double value representing the actual interest rate percentage, for example, 6.0% would be entered as 6.0)
· the amount that is to be deposited to the account each month (assume the deposit amount for each month is the same).
Once the user has supplied the initial deposit amount and interest rate for the account as well as the monthly deposit amount, the program should then proceed to calculate the new balance for the account (including interest earned) over a six month period (taking into account the additional amount being deposited and the interest earned for each month).
This should be done without using loops of any kind, as the emphasis is on using variables to help break down a repetitive process into here.
A simple way of handling the calculation of the balance for each month of the investment period is shown below:
balance = balance + monthly deposit amount
interest = balance (current) * ((interest rate / 12) / 100)
balance (new) = balance (current) + interest
Note that the interest rate is per annum (across the entire year), so the interest rate percentage for each month is equivalent to the yearly interest rate divided by 12.
The program should prompt for and accept three values from the user:
· the initial deposit amount (a double value representing the deposit value in dollars)
· the rate of interest earned per annum (yearly) on the account balance (a double value representing the actual interest rate percentage, for example, 6.0% would be entered as 6.0)
· the amount that is to be deposited to the account each month (assume the deposit amount for each month is the same).
Once the user has supplied the initial deposit amount and interest rate for the account as well as the monthly deposit amount, the program should then proceed to calculate the new balance for the account (including interest earned) over a six month period (taking into account the additional amount being deposited and the interest earned for each month).
This should be done without using loops of any kind, as the emphasis is on using variables to help break down a repetitive process into here.
A simple way of handling the calculation of the balance for each month of the investment period is shown below:
balance = balance + monthly deposit amount
interest = balance (current) * ((interest rate / 12) / 100)
balance (new) = balance (current) + interest
Note that the interest rate is per annum (across the entire year), so the interest rate percentage for each month is equivalent to the yearly interest rate divided by 12.
不许用循环...好吧
public class F_uck_u_boss{
public static void main(String[] args){
...
}
public static double after6month(double deposit, double interest, double permonth){
double balance = deposit+permonth;
interest /= 1200;
balance = after1month(balance, interest);
balance = after1month(balance, interest);
balance = after1month(balance, interest);
balance = after1month(balance, interest);
balance = after1month(balance, interest);
balance = after1month(balance, interest);
return balance;
}
public static double after1month(double deposit, double interest){
return deposit*(1+interest);
}
}
public class F_uck_u_boss{
public static void main(String[] args){
...
}
public static double after6month(double deposit, double interest, double permonth){
double balance = deposit+permonth;
interest /= 1200;
balance = after1month(balance, interest);
balance = after1month(balance, interest);
balance = after1month(balance, interest);
balance = after1month(balance, interest);
balance = after1month(balance, interest);
balance = after1month(balance, interest);
return balance;
}
public static double after1month(double deposit, double interest){
return deposit*(1+interest);
}
}