Question: Q2 const in class Based on lab 6, change the accountNo to constant member variable and change constructors correspondently. Name the program files as Ass6_2.h,

Q2 const in class Based on lab 6, change the accountNo to constant member variable and change constructors correspondently. Name the program files as Ass6_2.h, Ass6_2.cpp, and Ass6_2_test.cpp. Note, to simplify the problem, lets remove all overloaded constructors but leave chk(std::string,int no);.

// Ass6_2.h, Ass6_2.cpp, Ass6_2_test.cpp, inline.cpp.

Q3 In-line functions Based on Q2, change the constructor chk(std::string,int no) and member functions display and deposit into in-line functions.

/* * Lab6_3_test.cpp * NANE: * STUDENT NUMBER: */ #include "Lab6_3.h" #include using namespace std; int main(){ // create an acount //chk chk1; //chk chk1("Jone John"); chk chk1("Jone John",1234,1000,2,300); // input and select the menu while(1){ // build the menu int menu; cout << "Please select a function (0-3): " << endl; cout << "0---exit\t" << endl; cout << "1---display balance\t" << endl; cout << "2---deposit\t\t" << endl; cout << "3---withdraw\t\t" << endl; cout << "4---withdraw with a special fine\t\t" << endl; cin >> menu; switch (menu){ case 0:return 0; case 1: //display the balance chk1.display("CIBC"); break; case 2: float m; cout << "Input the amount of cash you want ot deposit: " << endl; cin >> m; chk1.deposit(m); break; case 3: cout << "Input the amount of cash you want ot withdraw: " << endl; cin >> m; chk1.withdraw(m); break; case 4: cout << "Input the amount of cash you want ot withdraw: " << endl; cin >> m; float sfine; cout << "Input the special fine rate: " << endl; cin >> sfine; chk1.withdraw(m,sfine); break; } } }

/* * Lab6_3.cpp * * * NAME: * STUDENT No: */ #include "Lab6_3.h" #include #include

using namespace std;

chk::chk(){ cout << "Please enter the user name (Without space): "; cin >> name; minimum_banlance = 1000; over_limit_charge = 5; balance = 0; srand(time(NULL)); acountNo = rand(); } chk::chk(string n){ name = n; minimum_banlance = 1000; over_limit_charge = 5; balance = 0; srand(time(NULL)); acountNo = rand(); } chk::chk(string n, int no){ name = n; acountNo = no; minimum_banlance = 1000; over_limit_charge = 5; balance = 0; } chk::chk(string n, int no, float mb){ name = n; acountNo = no; minimum_banlance = mb; over_limit_charge = 5; balance = 0; } chk::chk(string n, int no, float mb, float olc, float ini_balance){ name = n; acountNo = no; minimum_banlance = mb; over_limit_charge = olc; balance = ini_balance; } void chk::display(){ cout << "User:\t\t" << name << endl; cout << "Acount number:\t" << acountNo << endl; cout << "Balance:\t" << balance << endl; } void chk::display(string bankname){ cout << "Bank name:\t" << bankname << endl; cout << "User:\t\t" << name << endl; cout << "Acount number:\t" << acountNo << endl; cout << "Balance:\t" << balance << endl; } void chk::deposit(float m){ balance += m; } void chk::withdraw(float m){ if (balance < m){ cout << "There is not sufficent balance to withdraw!"; return; } balance -= m; if (balance < minimum_banlance) balance -= over_limit_charge; } void chk::withdraw(float m, float special){ if (balance < m){ cout << "There is not sufficent balance to withdraw!"; return; } balance -= m; if (balance < minimum_banlance) balance -= special; //apply special over limit rate here }

/* * Lab6_3.h * * Created on: Sep 11, 2017 * NAME: * STUDENT No: */

#include #include

class chk{ std::string name; int acountNo; float minimum_banlance; float over_limit_charge; float balance; public: chk(); chk(std::string); chk(std::string,int no); chk(std::string,int no, float mb); chk(std::string,int no, float mb,float olc, float ini_balance = 0); void display(); void display(std::string bank); void deposit(float m); void withdraw(float m); void withdraw(float m, float special); //apply special over limit charge };

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!