Question: C++ Question The instructions for this are to: define the class Contact which has three integer parts, for Example: Part1: 123, Part2: 456, Part3: 7890.
C++ Question
The instructions for this are to: define the class Contact which has three integer parts, for Example: Part1: 123, Part2: 456, Part3: 7890.
I believe that I did this but it does not compile completely. Please get my code to compile and write a driver program for it to test the parts and to show that it works.
MY CODE:
########## Loan.h ##########
class Loan { public: Loan(); Loan(Bank bank, ID id, float amount, float rate, int term); void set(); float payment(); void display(); private: Bank bank; ID id; // assume an unique integer in three integer parts float amount; // $ amount of the loan float rate; // annual interest rate int term; // number of months, length of the loan };
########## Bank.h ########## class Bank // Bank class definition { public: Bank(); Bank(int bank_ID, CONTACT phone, CONTACT fax); private: int bank_ID; // 4 digit integer Contact phone; // object three integer pieces, # # #, # # #, # # # # Contact fax; // object three integer pieces, # # #, # # #, # # # # };
############ Bank.cpp ############
#include #include "Bank.h"
using namespace std;
Bank::Bank() { bank_ID = 0; }
Bank::Bank(int id, Contact p, Contact f) { bank_ID = id; phone = p; fax = f; }
########## Contact.h ##########
class Contact {
private: int part1; int part2; int part3; public: Contact(); Contact(int p1, int p2, int p3); void display(); };
############ Contact.cpp ##########
#include "Contact.h" #include
using namespace std;
Contact::Contact() { part1 = 0; part2 = 0; part3 = 0; }
Contact::Contact(int p1, int p2, int p3) { part1 = p1; part2 = p2; part3 = p3; }
void Contact::display() { cout << part1 << "-" << part2 << "-" << part3 << endl; }
########## Loan.cpp ##########
// This part will go to the Loan.cpp file Loan::Loan( ) { }
Loan::Loan(ID I, float am, float rt, int trm) { id = I; amount = am; rate = rt; term = trm; }
void Loan::set( ) { int l, m, r; ID temp_id; // Initialize the loan1 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 = ID(l, 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() { id.display(); cout << amount << endl; cout << rate << endl; cout << term << endl; }
########## Main_prog ##########
//Please create one to show that it works. This is for CS1 so please use simple techniques and leave comments.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
