Final Project ( Studies Loan Calculator ) Lutfi/Firdaus/Amira
4 posters
Page 1 of 1
Final Project ( Studies Loan Calculator ) Lutfi/Firdaus/Amira
- Code:
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <windows.h>
using namespace std;
class loan
{
public:
double payment,rate,interest;
double amount;
int term;
void input();
double calPayment();
double calInterest();
void display();
};
void loan::input()
{
cout<<"Masukkan Jumlah Pinjaman: RM";
cin>>amount;
cout<<"Masukkan Kadar Kos Pentadbiran (%):";
cin>>rate;
rate=(rate/100);
cout<<"Masukkan Tempoh Bayaran (Tahun):";
cin>>term;
}
double loan::calPayment()
{
payment = (amount * pow((rate / 12) + 1, (term * 12))* rate / 12)/(pow(rate / 12 + 1, (term * 12)) - 1);
return payment;
}
double loan::calInterest()
{
interest=(amount*rate)/12;
return interest;
}
void loan::display()
{
system("cls");
cout << setiosflags(ios::fixed | ios::showpoint) << setprecision(2);
cout<<"Jumlah Pinjaman: RM"<<amount;
cout<<"\nTempoh Bayaran: "<<term<<" Tahun";
cout<<"\nJumlah Bayaran Bulanan: RM"<<payment;
cout<<"\nPurata Kos Pentadbiran Sebulan: RM"<<interest<<endl;
}
int main()
{
system("color F0");
loan tpk;
tpk.input();
tpk.calPayment();
tpk.calInterest();
tpk.display();
system("pause");
return 0;
}
Re: Final Project ( Studies Loan Calculator ) Lutfi/Firdaus/Amira
- Code:
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <conio.h>
#include <windows.h>
using namespace std;
//base class
class loan
{
protected:
double payment,rate,interest;
double amount,principle,tAmount;
int term,counter,check;
public:
int tTerm,setTableM,setTableY;
int pilih,pilihT;
void input();
void display();
void panduan();
void about();
void set()
{
tTerm=1;
setTableM=20;
setTableY=1;
pilih=1;
}
};
//derived class from class loan
class disLoan : public loan
{
public:
inline void calOther();
inline void pTableY();
inline void pTableM();
double calPayment();
void setting();
};
//input data
void loan::input()
{
cout<<"\nMasukkan Jumlah Pinjaman: RM";
cin>>amount;
tAmount=amount;//save amount to temporary memory
cout<<"Masukkan Kadar Kos Pentadbiran (%):";
cin>>rate;
rate=(rate/100);//change to %
cout<<"Masukkan Tempoh Bayaran:";
cin>>term;
}
//calculate payment
double disLoan::calPayment()
{
//calculate year input payment
if (tTerm==1)
payment = (amount * pow((rate / 12) + 1, (term * 12))* rate / 12)/(pow(rate / 12 + 1, (term * 12)) - 1);
//calculate month input payment
else if (tTerm==2)
payment = (amount * pow((rate / 12) + 1, term)* rate / 12)/(pow(rate / 12 + 1, term) - 1);
return payment;
}
//display basic payment
void loan::display()
{
system("cls");
//set to 2 decimal places
cout << setiosflags(ios::fixed | ios::showpoint) << setprecision(2);
cout<<"Jumlah Pinjaman: RM"<<tAmount; //display amount
cout<<"\nTempoh Bayaran: "<<term; //display term of payment
if (tTerm==1)
cout<<" Tahun"; //display if term in year
else if (tTerm==2)
cout<<" Bulan"; //display if term in month
cout<<"\nJumlah Bayaran Bulanan: RM"<<payment<<endl<<endl; //display payment
}
//calculate interest, principle,new amount
inline void disLoan::calOther()
{
counter++;
//initialize amount to 0 when check=0
if (check==0)
{
amount=0;
}
interest=(amount * rate)/12;
//calculate amount
amount=(amount-payment)+interest;
//calculate principle
principle=payment-interest;
}
//print payment table for month
inline void disLoan::pTableM()
{
amount=tAmount;
check=(int)amount;
counter=0;
int tCounter=0;
//table header
cout<<"Bulan\tBayaran\t\tFaedah\tPrinsip\tBaki Pinjaman" << endl;
cout<<setfill('-') << setw(80) << "-" << endl;
while(check !=0)
{
tCounter++;
calOther();
check=(int)amount;
if (check==0)
amount=0;
//table data
cout<<counter<<"\t"<<payment<<"\t\t"<<interest<<"\t"<<principle<<"\t"<<amount<<endl;
if (tCounter==setTableM && amount!=0)
{
cout<<"\nPress Enter to Continue";
tCounter=0;
getch();
system("cls");
//table header
cout<<"Bulan\tBayaran\t\tFaedah\tPrinsip\tBaki Pinjaman" << endl;
cout<<setfill('-') << setw(80) << "-" << endl;
}
}
cout<<"\n1. Papar semula\n";
cout<<"2. Menu Utama\n";
cout<<"3. Keluar\n";
do {
try{
cout<<"Pilihan: ";
cin>>pilihT;
//if want to display payment table again
if (pilihT==1)
{
display();
pTableM();
}
//return to main menu(main function)
else if (pilihT==2)
return;
//exit program
else if (pilihT==3)
pilih=5;
else
throw pilihT;
}//close try
catch (int b)
{
if (b>3 || b<1)
cout<<"Masukkan Salah\n"; //exception message
Sleep(1000);
}
}while (pilihT>3 || pilihT<1);
}
//print payment table for year
inline void disLoan::pTableY()
{
amount=tAmount;
check=(int)amount;
int Tyear=0;
for (int year=1;year<=term;year++)
{
counter=0;
//table header
cout<<"Tahun "<<year<<endl;
cout<<"Bulan\tBayaran\t\tFaedah\tPrinsip\tBaki Pinjaman" << endl;
cout<<setfill('-') << setw(80) << "-" << endl;
while(check !=0)
{
calOther();
check=(int)amount;
if (check==0)
amount=0;
//table data
cout<<counter<<"\t"<<payment<<"\t\t"<<interest<<"\t"<<principle<<"\t"<<amount<<endl;
if (counter == 12 && check!=0)
{
Tyear++;
if(Tyear==setTableY)
{
cout<<"\nPress Enter to Continue";
Tyear=0;
getch();
system("cls");
}
cout<<endl;
break;
}
}
}
cout<<"\n1. Papar semula\n";
cout<<"2. Menu Utama\n";
cout<<"3. Keluar\n";
do {
try{
cout<<"Pilihan: ";
cin>>pilihT;
//if want to display payment table again
if (pilihT==1)
{
display();
pTableY();
}
//return to main menu(main function)
else if (pilihT==2)
return;
//exit program
else if (pilihT==3)
pilih=5;
else
throw pilihT;
}//close try
catch (int b)
{
if (b>3 || b<1)
cout<<"Masukkan Salah\n"; //exception message
Sleep(1000);
}
}while (pilihT>3 || pilihT<1);
}
void disLoan::setting()
{
int temp[2],set;
char save,tSave;
cout<<"\n1.Tahun\n";
cout<<"2.Bulan\n";
cout<<"Jenis Tempoh Bayaran:";
cin>>set;
if (set==1)
{
cout<<"Jumlah Paparan Jadual:";
cin>>temp[0];
}
else if (set==2)
{
cout<<"Jumlah Paparan Jadual:";
cin>>temp[1];
}
do
{
cout<<"Simpan Tetapan ( Y / T ):";
cin>>save;
save=toupper(save);//change to upper case
tSave=save;//save data to temporary memory
try{
//save the setting
if (save=='Y')
{
tTerm=set;
if (set==1)
{
setTableY=temp[0];
}
else if (set==2)
{
setTableM=temp[1];
}
cout<<"Tetapan Disimpan";
Sleep(1000);
break;//out from loop
}
else if (save=='T')
{
cout<<"Tetapan Tidak Disimpan";
Sleep(1000);
break;//out from loop
}
else
{
throw tSave;
}
}//close try
catch (char a)
{
if (a != 'Y' || a != 'T')
cout<<"Masukkan Salah\n"; //exception message
}
}while(save!='Y'||save!='T');
}
//display about the program
void loan::about()
{
system("cls");
cout<<"\n Kalkulator Pinjaman v2.4\n";
cout<<"\n Institut Teknikal Jepun-Malaysia\n";
cout<<" Jabatan Teknologi Kejuruteraan Komputer\n";
cout<<"-----------------------------------------\n";
cout<<"\nAhli Kumpulan:";
cout<<"\n\tMohammad Lutfi Haris\n";
cout<<"\tMohammad Firdaus Syafik Jefridin\n";
cout<<"\tNur Amira Abd Rasid\n";
cout<<"\nTarikh:";
cout<<"\n7/12/2009\n";
getch();
}
//display manual user
void loan::panduan()
{
system("cls");
cout<<"\nPanduan Penggunaan"
<<"\n\nProgram ini adalah untuk kegunaan penuntut-penuntut IPT yang melakukan pinjaman pembelajaran"
<<" dari Tabung Pembangunan Kemahiran (TPK) untuk mengira jumlah \npembayaran yang akan dilakukan "
<<"setelah tamat pengajian di IPT.Selain itu, semua penuntut dapat melihat jadual pembayaran yang disediakan "
<<"dan mengetahui baki \npinjaman setelah pembayaran dibuat.\n"
<<"\nUntuk menggunakan program ini anda perlu memilihan antara 5 pilihan.\n";
cout<<" 1. Kalkulator\n";
cout<<" 2. Tetapan\n";
cout<<" 3. Panduan Penggunaan\n";
cout<<" 4. Info Program\n";
cout<<" 5. Keluar\n";
cout<<"\nJika anda memilih pilihan 1, anda telah memilih untuk melakukan pengiraan \npinjaman anda. Anda akan diminta"
<<" supaya memasukkan jumlah pinjaman, kadar kos \npentadbiran dan tempoh pembayaran. Jika anda menetapkan tetapan, "
<<"tempoh \npembayaran adalah mengikut tahun. Jika anda telah menetapkan tetapan sila \nmasukkan tempoh pembayaran "
<<"mengikut pilihan yang telah anda lakukan. Setelah \nmemasukkan tempoh pembayaran, program akan secara automatik akan"
<<" melakukan \npengiraan dan memaparkan jadual pembayaran anda. Anda boleh memaparkan semula \njadual pembayaran anda "
<<"dengan beberapa pilihan seterusnya.\n"
<<"\nJika anda memilih pilihan 2, anda akan memasuki bahagian tetapan. Anda boleh \nmelakukan beberapa tetapan mengikut "
<<"kesesuaian anda. Semasa memasuki bahagian \ntetapan anda diminta untuk memilih jenis tempoh pembayaran sama ada bulan "
<<"atau \ntahun. Setelah memilih jenis tempoh pembayaran, anda diminta untuk memasukkan \nnilai paparan jadual yang akan "
<<"dipaparkan iaitu jika pilihan anda adalah 'tahun'anda perlu memasukkan nilai paparan jadual pada satu masa dan jika "
<<"pilihan anda adalah bulan pula, anda perlu memasukkan nilai jumlah paparan jadual yang akan \ndipaparkan pada satu masa."
<<"Setelah selesai, anda perlu menyimpan tetapan tersebutdengan memilih anda 'Y' atau 'T'.\n"
<<"\nJika pilihan anda adalah 3 pula, ia akan memaparkan panduan penggunaan seperti \nmana yang sedang dipaparkan sekarang ini."
<<"Jika anda memilih pilihan 4, anda akan melihat info program iaitu versi, kumpulan pencipta, tarikh dicipta dan nama \nprogram"
<<"\n\nUntuk keluar daripada meneruskan program anda boleh memilih pilihan 5 iaitu \npilihan 'Keluar'.";
getch();
}
//main function
int main()
{
//set color background and font
system("color F0");
disLoan tpk;//create object
tpk.set();//set initialize value
while(tpk.pilih!=5)
{
try{
system("cls");
cout<<"Kalkulator Pinjaman\n";
cout<<"Tabung Pembangunan Kemahiran (TPK)\n";
cout<<setfill('-') << setw(80) << "-" << endl;
cout<<"1. Kalkulator\n";
cout<<"2. Tetapan\n";
cout<<"3. Panduan Penggunaan\n";
cout<<"4. Info Program\n";
cout<<"5. Keluar\n";
cout<<"\nSila masukkan pilihan anda:";
cin>>tpk.pilih;
//start calculator
if (tpk.pilih==1)
{
tpk.input();
tpk.calPayment();
//dispaly first payment table
tpk.display();
if (tpk.tTerm==1)
tpk.pTableY();
else if (tpk.tTerm==2)
tpk.pTableM();
}
//enter setting (by default tTerm=1 setTableY=1 setTableM=20
else if (tpk.pilih==2)
{
tpk.setting();
}
//display manual user
else if (tpk.pilih==3)
{
tpk.panduan();
}
//display about the program
else if (tpk.pilih==4)
{
tpk.about();
}
//exit the program.
else if(tpk.pilih==5)
{
system("pause");
return 0;
}
else
{
throw tpk.pilih;
}
}//close try
catch(int x)
{
if (x>5 || x<1)
cout<<"Sila pilih antara 1-5\n"; //exception message
Sleep(1000);
}
}//close while
system("pause");
}
Re: Final Project ( Studies Loan Calculator ) Lutfi/Firdaus/Amira
Eh..
nie bkan mcm program kt tenet 2 kew..
nie bkan mcm program kt tenet 2 kew..
SuFri- Number of posts : 2
Age : 32
Registration date : 2009-08-05
Re: Final Project ( Studies Loan Calculator ) Lutfi/Firdaus/Amira
nie bkan hasil kjer sndri..
stkt edit jer..
x pyah la..
stkt edit jer..
x pyah la..
zakaria- Number of posts : 5
Age : 32
Registration date : 2009-08-05
Re: Final Project ( Studies Loan Calculator ) Lutfi/Firdaus/Amira
owh.. betul ker... ahli kumpulan sila komen
Anyway, this project is the best
Anyway, this project is the best
Re: Final Project ( Studies Loan Calculator ) Lutfi/Firdaus/Amira
fitnah smua 2...
mmg la ade program kt tenet..
tp smua bnde xme dgn program yg sy buat...
kalo nk tgk sy boleh upload source code internet yg sy dpt 2...
mmg la ade program kt tenet..
tp smua bnde xme dgn program yg sy buat...
kalo nk tgk sy boleh upload source code internet yg sy dpt 2...
Re: Final Project ( Studies Loan Calculator ) Lutfi/Firdaus/Amira
- Code:
#include <iostream>
#include <iomanip>
#include <string>
#include <math.h>
#include <windows.h>
//set namespace to eliminate the need for std:: prefixes
using namespace std;
//public defines
int runloan();
bool isvalidnumber(string * puserinput);
void printheader(int iPrintYear);
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); //get handle to standard output
int main()
{
//set color of output to intense white text with standard black background
SetConsoleTextAttribute(hConsole, 15 | 1);
runloan(); //run the main loan routine
system("pause");
return 0;
}
int runloan()
{
string userinput;
double amount, rate, term, payment, interest, principle;
int iCounter=0, iYear=1, loanchecker;
string * puserinput = &userinput; // pointer to user input variable
//formatting output with a decimal place of 2
cout << setiosflags(ios::fixed | ios::showpoint) << setprecision(2);
//get loan amount routine
userinput = "";
while(!isvalidnumber(puserinput) || userinput.length() == 0) //loop till valid numeric number is found and is not empty
{
cout << "Enter the amount of loan: ";
getline(cin, userinput);
}
amount = atof(userinput.c_str()); //convert string to double
loanchecker = (int)amount;
//get interest rate routine
userinput = "";
while(!isvalidnumber(puserinput) || userinput.length() == 0) //loop till valid numeric number is found and is not empty
{
cout << "Enter the interest rate: ";
getline(cin, userinput);
}
rate = atof(userinput.c_str()); //convert string to double
//if rate is a not a decimal convert value to decimal
if(rate > 1)
rate = (rate/100);
//get term routine
userinput = "";
while(!isvalidnumber(puserinput) || userinput.length() == 0) //loop till valid numeric number is found and is not empty
{
cout << "Enter the total number of years: ";
getline(cin, userinput);
}
term = atof(userinput.c_str()); //convert string to double
//calculate the monthly payment
payment = (amount * pow((rate / 12) + 1, (term * 12))* rate / 12)/(pow(rate / 12 + 1, (term * 12)) - 1);
//output loan specific data header information
cout << "\nUser Specified Loan Details" << endl;
cout << setfill('-') << setw(80) << "-" << endl;
//output report hearder information
printheader(iYear);
//output the monthly payment
while (loanchecker != 0)
{
//increment counters
iCounter++;
//calculate interset rate based on remaining loan amount
interest = (amount * rate) / 12;
//calculate new loan amount after payment plus interest
amount = (amount - payment) + interest;
//calculate principle by subtracting the interest
principle = payment - interest;
loanchecker = (int)amount;
//prevent a negative number once loan is paid off
if (loanchecker == 0) amount = 0;
//output loan information for a specific month
cout << iCounter << "\t" << payment << "\t\t" << interest << "\t\t" << principle << "\t\t" << amount << endl;
if (iCounter == 12 && amount != 0) //allow screen data to be buffered if the loan amount is not 0 per year
{
iCounter = 0;
iYear++;
cout << "Press enter to continue...";
getline(cin, userinput);
//output report hearder information
printheader(iYear);
}
}
return 0;
}
bool isvalidnumber(string * puserinput)
{
bool decimal = true;
string checkstring = *puserinput; //convert memory location to string
for(int count=0; count < (int)checkstring.length(); count++) //loop the char array for invalid numeric data
{
if(isdigit(checkstring[count]) || checkstring[count] == '.' && decimal == true)
{
if(checkstring[count]== '.') //only allows one decimal place
{
decimal = false;
}
}
else
{
return false; //numeric validation failed
}
}
return true; //numeric validation success
}
void printheader(int iPrintYear)
{
//clear screen
system("cls");
//set color of output
SetConsoleTextAttribute(hConsole, 12);
//output current reporting year
cout << "\nDetails for year: " << iPrintYear << endl;
//set color of output
SetConsoleTextAttribute(hConsole, 14);
//output loan payment specific data header information
cout << "Month\tPayment\t\tInterest\tPrinciple\tLoan Amount" << endl;
cout << setfill('-') << setw(80) << "-" << endl;
//reset color of output to initial color text
SetConsoleTextAttribute(hConsole, 15);
}
utk mengelakkan dengki ngan fitnah org2 kat ats 2.
ni source code yg aku dpt dr internet 2.
boleh tgk dan bandingkan mcm mne.
kalo tgk output mmg sama tp bandingkan cara penulisan program.
org2 yg pandai pasal program saja tahu sama atau tidak source code ni.
kalo rse2 xtau nk bezakan baik xyah blaja c++.
Re: Final Project ( Studies Loan Calculator ) Lutfi/Firdaus/Amira
Ok.... saya faham.. dari masa presentation pun saya dah tau, group lutfi faham apa yg dibuat.
It's not a big issue.
Ok.. happy holiday to u all
It's not a big issue.
Ok.. happy holiday to u all
Similar topics
» final project(baiti, fiza, putri)
» Final Project Calculate The Electricity Usage And Charge(Sufri,Yazid,Zakaria)
» final projek (CGPA) zata rina,qamariah,rahayu
» Final Project Calculate The Electricity Usage And Charge(Sufri,Yazid,Zakaria)
» final projek (CGPA) zata rina,qamariah,rahayu
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum