Jump to content
Sign in to follow this  
akdenme

Mintak Tolong Betulkan Apa Yg Silap Dlm Code Nie.

Recommended Posts

output program aku patut jadi cenggini..
aku amik dlm buku introduction C++, jd tgh try la nie wat program..

Loan Amount (RM) : 10000 [Enter]
Number of Years : 1 [Enter]
Annual Interest Rate : 7 [Enter]

Monthly Payment (RM) : 865.26
Total Payment (RM) : 10383.21

[b]Payment[/b] [b]Interest[/b] [b]Principal[/b] [b]Balance[/b]
[b]1.[/b] 58.33 806.93 9193.07
[b]2.[/b] 53.62 811.64 8381.43
...
[b]11.[/b] 10.00 855.26 860.27
[b]12.[/b] 5.01 860.25 0.01

[NOTE: The balance after the last payment may not be zero. If so, the last payment should be the normal monthly payment plus the final balance]

OKE, PROGRAM DYE AKU DAH BUAT NIE DYE...

#include <iostream.h>
#include <conio.h>
#include <math.h>
#include <iomanip.h>


void main()
{
double AnualInterestRate, monthlyInterestRate, loan_amount, monthlyPayment, total_payment, interest, principal, balance;
int num_year;

cout << "Loan Amount: ";
cin >> loan_amount;

cout << "Number of Years: " ;
cin >> num_year;

cout << "Annual Interest Rate: ";
cin >> AnualInterestRate;

monthlyInterestRate = AnualInterestRate / 1200;

monthlyPayment = loan_amount * monthlyInterestRate / (1 - 1 / pow(1 + monthlyInterestRate, num_year * 12));
total_payment = monthlyPayment * num_year * 12;


cout << "\nCalculation... " << endl;

cout << "\nMonthly Payment: " << monthlyPayment << endl;
cout << "Total Payment: " << total_payment << endl;



cout <<setw(0) << "\nPayment#" << setw(14) << "Interest" << setw(15) << "Principal" << setw(20) << "Balance" <<endl;

for (int i = 1; i <= num_year * 12; i++)
{
interest = monthlyInterestRate * balance;
principal = monthlyPayment - interest;
balance = balance - principal;



cout << setw(0)<< i << setw(20) << interest << setw(14) << principal << setw(20) << balance << endl;
}




getch();
}

MASALAH AKU SKUNK NIE KENAPA
1.INTEREST, BALANCE,principal DYE BOLEH JD (-ve)
2.cam ner nak buat no belakang tuh yg contoh:12.3455 jd 12.34 sahaja..
3.apa maksud "posible use of 'balance' before definition..

MAAF OTAI SUME YG OUTPUT AKU XRETI SGT NAK SUSUN TP HARAP OTAI PAHAM>> tp bler otai dah copy code tuh myb taw kowt..

otai3, sila bantu..

Share this post


Link to post
Share on other sites
2.cam ner nak buat no belakang tuh yg contoh:12.3455 jd 12.34 sahaja..

yg ni keluar kat mana? main2 kat declaration dier

Share this post


Link to post
Share on other sites
apsal

[quote]monthlyInterestRate = AnualInterestRate / 1200;[/quote]

bahagi 1200?
patotnya bahagi 12 jer lah kan...

1 lg nak tanya ni interest dikira ke atas baki pinjaman atau dah fix pd jumlah pinjaman?
setau aku kalo konvensional punya loan interest dah fix ke atas total pinjaman. Edited by otai_g

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...