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
/* * Lab6_3.cpp * * * NAME: * STUDENT No: */ #include "Lab6_3.h" #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
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
Get step-by-step solutions from verified subject matter experts
