program pegadaian; uses wincrt; var annualrate,balance,interest,payment,monthlyrate:real; j,month:integer;
begin writeln('what is the current mortgage balance?'); writeln('omit $.'); readln(balance); writeln('what is the annual interest rate?'); writeln('omit %.'); readln(annualrate); writeln('what is the monthly payment?'); writeln('omit $.'); readln(payment); monthlyrate:=annualrate/12; monthlyrate:=0.01*monthlyrate;{express as decimal} writeln('the next 12 months;'); writeln;{blank line before table} writeln('Month':10,'interest':10,'balance':10); for j:=1 to 30 do{draw a line under the heading} write('_'); writeln;{move to beginning of next line} writeln;{leave a blank} for month:=1 to 12 do begin interest:=monthlyrate*balance; balance:=balance+interest-payment; write(month:10); write(interest:10:2); write(balance:10:2); end; end.
1. LACAK PERUBAHAN NILAI VARIABELNYA 2. DESKRIPSIKAN ALGORITMA PROGRAM DENGAN PSEUDOCODE 3. PECAHKAN PROGRAM DALAM MODUL-MODUL MENGGUNAKAN PROCEDURE
kokosip
1. Lacak perubahan variabel... ada di baris ini, saya jelaskan perbaris -interest:=monthlyrate*balance; pada syntax ini, variabel "interest" merupakan perkalian dari "monthlyrate" dan "balance", arti nya value var ini pasti berubah.
- balance:=balance+interest-payment; pada syntax ini, variabel "balance" merupakan hasil dari "balance+interest-payment", arti nya value var ini pasti berubah.
untuk variabel "annualrate", tidak ada perubahan nilai,,, karena hanya di pake untuk perkalian saja, pada baris ini monthlyrate:=annualrate/12;
utk var monthlyrate, dia berubah value pada baris ini monthlyrate:=annualrate/12; monthlyrate:=0.01*monthlyrate;{express as decimal}
2. Pseudocode nya 1. Masukan Value "balance", "annualrate" dan "payment" 2. hitung mountlyrate <- annualrate/12 3. hitung monthlyrate:=0.01*monthlyrate; 4. cetak garis untuk pembatas 5. perulangan dari bulan 1 sampe ke 12 6. setiap perulangan hitung interest dan balance 7. interest:=monthlyrate*balance; 8. balance:=balance+interest-payment; 9. Cetak hasil perhitungan
3. Pecah program pake procedure program pegadaian; uses wincrt;
{INI PROCEDURE NYA} Procedure count(var interest : real; var payment : real; var monthlyrate : real; var balance : real); var month:integer; Begin for month:=1 to 12 do begin interest:=monthlyrate*balance; balance:=balance+interest-payment; write(month:10); write(interest:10:2); write(balance:10:2); end; End;
var annualrate,balance,interest,payment,monthlyrate:real; j,month:integer;
begin writeln('what is the current mortgage balance?'); writeln('omit $.'); readln(balance);
writeln('what is the annual interest rate?'); writeln('omit %.'); readln(annualrate);
writeln('what is the monthly payment?'); writeln('omit $.'); readln(payment);
monthlyrate:=annualrate/12; monthlyrate:=0.01*monthlyrate; {express as decimal} writeln('the next 12 months;'); writeln;{blank line before table} writeln('Month':10,'interest':10,'balance':10);
for j:=1 to 30 do { draw a line under the heading} write('_');
writeln;{move to beginning of next line} writeln;{leave a blank} { PADA BAGIAN INI ADALAH UTK PEMANGGILAN PROCEDURE } count(interest, payment, monthlyrate, balance); end.
ada di baris ini, saya jelaskan perbaris
-interest:=monthlyrate*balance;
pada syntax ini, variabel "interest" merupakan perkalian dari "monthlyrate" dan "balance", arti nya value var ini pasti berubah.
- balance:=balance+interest-payment;
pada syntax ini, variabel "balance" merupakan hasil dari "balance+interest-payment", arti nya value var ini pasti berubah.
untuk variabel "annualrate", tidak ada perubahan nilai,,, karena hanya di pake untuk perkalian saja, pada baris ini
monthlyrate:=annualrate/12;
utk var monthlyrate, dia berubah value pada baris ini
monthlyrate:=annualrate/12;
monthlyrate:=0.01*monthlyrate;{express as decimal}
2. Pseudocode nya
1. Masukan Value "balance", "annualrate" dan "payment"
2. hitung mountlyrate <- annualrate/12
3. hitung monthlyrate:=0.01*monthlyrate;
4. cetak garis untuk pembatas
5. perulangan dari bulan 1 sampe ke 12
6. setiap perulangan hitung interest dan balance
7. interest:=monthlyrate*balance;
8. balance:=balance+interest-payment;
9. Cetak hasil perhitungan
3. Pecah program pake procedure
program pegadaian;
uses wincrt;
{INI PROCEDURE NYA}
Procedure count(var interest : real; var payment : real; var monthlyrate : real; var balance : real);
var month:integer;
Begin
for month:=1 to 12 do
begin
interest:=monthlyrate*balance;
balance:=balance+interest-payment;
write(month:10);
write(interest:10:2);
write(balance:10:2);
end;
End;
var
annualrate,balance,interest,payment,monthlyrate:real;
j,month:integer;
begin
writeln('what is the current mortgage balance?');
writeln('omit $.');
readln(balance);
writeln('what is the annual interest rate?');
writeln('omit %.');
readln(annualrate);
writeln('what is the monthly payment?');
writeln('omit $.');
readln(payment);
monthlyrate:=annualrate/12;
monthlyrate:=0.01*monthlyrate; {express as decimal}
writeln('the next 12 months;');
writeln;{blank line before table}
writeln('Month':10,'interest':10,'balance':10);
for j:=1 to 30 do { draw a line under the heading}
write('_');
writeln;{move to beginning of next line}
writeln;{leave a blank}
{ PADA BAGIAN INI ADALAH UTK PEMANGGILAN PROCEDURE }
count(interest, payment, monthlyrate, balance);
end.