Question: In C++ Complete program 1.cpp by defining the member functions display and payment for class loan . Note that the display function will display all

In C++

Complete program 1.cpp by defining the member functions display and payment for class loan. Note that the display function will display all the information about a loan, i.e.,

ID:

Amount:

Rate:

Term:

You will display the monthly payment in the main by assigning the returned value from the payment function to a variable of type float. Suppose, in the main we have declared:

.....

float p;

Loan loan1;

loan1.set( );

.....

loan1.display( ) // will display the data members of loan1

p = loan1.payment( ) // will return the monthly payment of loan1

program 1:

// 1.cpp - This program is a driver written to demonstrate how the set function works.

#include

using namespace std;

class Loan // Loan is called structure tag

{

public:

void set( );

float payment( );

void display( );

private:

int ID; // assume an unique integer between 1111-9999

float amount; // $ amount of the loan

float rate; // annual interest rate

int term; // number of months, length of the loan

};

int main( )

{

Loan loan1;

loan1.set( );

return 0;

}

void Loan::set( )

{

// Initialize the loan1 object

cout << "Enter the ID of this loan ";

cin >> ID;

cout << "Enter the amount of this loan ";

cin >> amount;

cout << "Enter the annual interest rate of this loan (in %) ";

cin >> rate;

cout << "Enter the term (number of months, length of the loan) ";

cin >> term;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!