Given a Loan class, name the necessary fields and methods that we would need in this class. Be creative in your naming of variables and methods.
class Loan{
//Data Members
public:
int loan_amount;
int month_interest;
int emi_number; //number of payments
//Methods
//constructor
Loan ( int amt, int rate, int num){
loan_amount = amt;
month_interest = rate;
emi_number = num;
}
//get loan amount
int getamt(){
return loan_amount;
}
//year tenure of loan
int getloan_period(){
return emi_number/12;
}
//monthly payment
double getemi(){
int x = (1+ month_interest)*emi_number;
double emia = loan_amount * month_interest*x/(x-1);
return emia;
}
};
Get Answers For Free
Most questions answered within 1 hours.