|
查看: 1702|回复: 16
|
Java问题,帮帮忙。
[复制链接]
|
|
|
Write a program that lets the user enter the loan amount and loan period in number of years and displays the monthly and total payments for each interest rate starting from 5% to 8%, with an increment of 1/8. Suppose you enter the loan amount 10,000 for five year; display a table as follows:
Loan Amount: 10000
Number of Years: 5
Interest Rate Monthly Payment Total Payment
5% 188.71 11322.74
5.125% 189.28 11357.13
5.25% 189.85 11391.59
…
7.85% 202.16 12129.97
8.0% 202.76 12165.83 |
|
|
|
|
|
|
|
|
|
|
发表于 18-9-2008 11:15 PM
|
显示全部楼层
瓦老~~功课不自己做 将来肯定保你后悔 |
|
|
|
|
|
|
|
|
|
|
发表于 18-9-2008 11:55 PM
|
显示全部楼层
这样的问题是非常普通的练习题吧了..
如果连这也有问题..
我想你的JAVA课要白修了..  |
|
|
|
|
|
|
|
|
|
|
发表于 19-9-2008 12:04 AM
|
显示全部楼层
|
我对java也有少少知识,看你的问题大概也不会很难。你的老师大概也有叫你那些basic的coding吧? 不然去goggle search就因该有答案了。如果还是有问题你可以add我的msn:owen_hebe@hotmail.com 本人最讨厌见死不救的人。不帮就算了,还要在那边讲多多废话。。。:@:@:@ |
|
|
|
|
|
|
|
|
|
|
发表于 19-9-2008 12:14 AM
|
显示全部楼层
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 19-9-2008 12:31 AM
|
显示全部楼层
|
是做不出来呀!前面做了一点,但后面那边的那些我不会写。 |
|
|
|
|
|
|
|
|
|
|
发表于 19-9-2008 09:29 PM
|
显示全部楼层
回复 4# Darren10 的帖子
hi...
溺愛式教育是不對的
樓主應該問問題
或者自己先嘗試
然後貼出自己的code
給大家看看有什麼不對的地方
這樣才是正確的學習態度
 |
|
|
|
|
|
|
|
|
|
|
发表于 19-9-2008 09:39 PM
|
显示全部楼层
|
讲真的,你的题目很乱水。我完全想不到那些数目是怎样算出来的。你解释一下? |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 20-9-2008 09:00 PM
|
显示全部楼层
回复 7# cheng1986 的帖子
谢谢你!这是我做的,但答案有点怪。
int year = 5;
double interest_rate = 5;
double loan_amount = 10000;
double monthly_payment = 0;
double total_payment = 0;
char percent = '%';
Scanner scan = new Scanner(System.in);
System.out.println("Loan amount: " + loan_amount);
System.out.println("Number of Years: " + year);
System.out.println("Interest Rate \t Monthly Payment(RM) \t Total Payment(RM)");
do{
interest_rate = (interest_rate * 1/8)+ interest_rate;
total_payment = year * (interest_rate * loan_amount);
monthly_payment = total_payment / (year * 12);
System.out.printf("%.3f %-10c %-23.2f %.2f\n",
interest_rate,percent,monthly_payment,total_payment);
}
while(interest_rate <= 8.0); |
|
|
|
|
|
|
|
|
|
|
发表于 21-9-2008 12:28 AM
|
显示全部楼层
原帖由 skyblueyin 于 20-9-2008 09:00 PM 发表 
谢谢你!这是我做的,但答案有点怪。
int year = 5;
double interest_rate = 5;
double loan_amount = 10000;
double monthly_payment = 0;
double total_payment = 0;
char percent = '%';
Scanner ...
int count = 0;
do {
interest_rate = (count * 0.125) + interest_rate;
total_payment = year * (interest_rate/100 * loan_amount)+loan_amount;
monthly_payment = total_payment / (year * 12);
count=count+1;
System.out.printf("%.3f %-10c %-23.2f %.2f\n", interest_rate,
percent, monthly_payment, total_payment);
} while (interest_rate <= 8.0);
你的total payment错了
1)你算的利息要加上(loan amount)
2) 5% 的意思是 0.05, 所以你的利息要除100 |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 21-9-2008 04:39 PM
|
显示全部楼层
回复 10# winmxaa 的帖子
那方程式是老师给的,我也觉得有点怪怪。
这是什么意思:%-10c? |
|
|
|
|
|
|
|
|
|
|
发表于 21-9-2008 10:37 PM
|
显示全部楼层
原帖由 skyblueyin 于 21-9-2008 04:39 PM 发表 
那方程式是老师给的,我也觉得有点怪怪。
这是什么意思:%-10c?
这是tab的东西,这个没问题! |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 24-9-2008 07:53 PM
|
显示全部楼层
|
|
|
|
|
|
|
|
|
|
发表于 25-9-2008 02:02 AM
|
显示全部楼层
|
|
|
|
|
|
|
|
|
|
发表于 1-10-2008 03:57 AM
|
显示全部楼层
编程嘛。。
个人觉得Language/Syntax 在其次,重要的是Logic/algorithm
1. 先做分析
- 2个 user inputs (Loan amount & Loan period)
- 2 Fomulae required (get monthly payment & total payment)
2. Flow & Logic
function total payment = ($loan amount * rate% * loan period) + loan amount
function montly payment = total payment/load period/12
Get Loan amount
Get Loand Period
Loop and display Loan detail with the rate of 5% to 8% (incremental of 1/8)
Display Rate, Monthly Payment, Total Payment
End loop
3. 把以上的Logic写成Code就可以了
曾经我就经常帮我的同学做作业
最后导致他在考场不会作答,结果重读
我帮他,但也害了他
如果当时我没帮他,也许他自己就会尽力尝试
考试就不会不及格了
编程是需要锻炼和实习的 |
|
|
|
|
|
|
|
|
|
|
发表于 28-10-2008 05:47 PM
|
显示全部楼层
你们讲的对, 不过,我很奇怪,就是那些senior也有说做多点练习就懂了。。。
其实, 我要说不懂也不是,但也不可以说我很懂。。。
我很想精通在这一方面,不过不懂应该如何IMPROVE....
请问你们可以分享一下吗???
谢罗。。。。 |
|
|
|
|
|
|
|
|
|
|
发表于 28-10-2008 09:07 PM
|
显示全部楼层
|
|
|
|
|
|
|
|
| |
本周最热论坛帖子
|