Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Exercise 5 . 2 Use operator overloading to overload = = ( in classes where necessary ) such that every time you run the program,
Exercise Use operator overloading to overload in classes where necessary such that every time you run the program, it will tell you whether the two loans are the same, ie ID amount, rate, and term are the same for both. Call you new program excpp Pcpp This program is a driver written to demonstrate how we can use a
class inside another one.
#include
using namespace std;
class ID
public:
ID;
IDint int, int;
void display;
private:
int left;
int middle;
int right;
;
class Loan Loan is called structure tag
public:
Loan;
LoanID id float amount, float rate, int term;
void set;
float payment;
void display;
private:
ID id; assume an unique integer between
float amount; $ amount of the loan
float rate; annual interest rate
int term; number of months, length of the loan
;
int main
Loan loanID; initialize to values given
Loan loan;
cout "Display loan
;
loandisplay;
loanset; set the values
cout "Display loan
;
loandisplay;
return ;
ID::ID
use default values
ID::IDint l int m int r
left l;
middle m;
right r;
void ID::display
cout left middle right endl;
Loan::Loan
Loan::LoanID I, float am float rt int trm
id I;
amount am;
rate rt;
term trm;
void Loan::set
int l m r;
ID tempid;
Initialize the loan object
cout "Enter the left part of the loan ID
;
cin l;
cout "Enter the middle part of the loan ID
;
cin m;
cout "Enter the right part of the loan ID
;
cin r;
id IDl m r;
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;
void Loan::display
iddisplay;
cout amount endl;
cout rate endl;
cout term endl;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started