设计一个程序,使用户可以查看利率及其各自每月付款的几种选择。该程序必须能够提示贷款金额及其期限(以年为单位)。然后,它将显示每个利率的月度付款和总付款,从3.50%到8.00%,以0.25为增量。必须使用以下公式进行计算:
P =(r * A)/(1 –(1 + r)–N)
哪里
P =每月付款
A =贷款金额
r =利率(r =(年利率/ 100)/ 12)
N =付款次数(N =年数* 12)
总付款额= P x N
用伪代码编写算法。
我已经创建了伪代码,但是我不确定是否有任何错误或错过的任何内容。
1.0 START
2.0 Set Float rate = 3.5
3.0 Set Int loan_amount = 0
4.0 Set Int year = 0
5.0 Set Int N = year*12
6.0 Set Float P = 0
7.0 Set Float Total_Payment = 0
8.0 Input loan_amount
9.0 Input year
10.0 Add a header "Annual Interest Rate" to the output
11.0 Add a header "Monthly Payment (RM)" to the output
12.0 Add a header "Total Payment" to the output
13.0 Insert a new line
14.0 While (rate<8.0)
15.0 Start
15.1 Calculate P=(rate*loan_amount)/(1-(1+rate)–N)
15.2 Calculate Total_Payment = P*N
15.3 Print rate to header "Annual Interest Rate"
15.4 Print P to header "Monthly Payment (RM)"
15.5 Print Total_Payment to header "Total Payment"
15.6 Insert a new line
15.7 Set Total_Payment to 0
15.8 Set P = 0
15.9 Increase rate by 0.25
16.0 End While
17.0 END