Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

a)Implement the following Checkbook member functions by writing the class member

ID: 653833 • Letter: A

Question

a)Implement the following Checkbook member functions by writing the class member function procedures outside of the class specification
a. Open
b. WriteCheck
c. MakeDeposit
d. CurrentBalance
   ANSWER:
     

b)Write a segment of client code that declares two Checkbook objects, one for a personal checkbook and one for a business account.
ANSWER:

c). For the personal checkbook in Question b), write a segment of client code that opens the account with an initial balance of $300.00, writes two checks $50.25 and $150.00, deposits $87.34 into the account, and prints out the resulting balance. (2 pts)
ANSWER:

d) For the Checkbook class, replace the Open function with two C++ class constructors. One (the default constructor) initializes the account balance to zero. The other initializes the balance to an amount passed as an argument.
a. Revise the class declaration.
b. Implement the two class constructors.
ANSWER:

Explanation / Answer

#include <iostream>
using namespace std;
// class declaration
class checkbook {

private:
double deposit_amt;        // deposit amount
double check_amt;       // amount to be written on check
double total_balance;       // remaining balance after a transaction

public:
   void open(double init_amt);    // initialize values
      
   void write_check(double input_amt);   // subtract from checkbook  
  
   void make_deposit(double input_amt);    // add to checkbook
  
   double current_balance();   // returns balance

};

a)
a.
   // initialize variables with the initial deposite amount
inline void checkbook::open(double init_amt)
{
   deposit_amt = init_amt;
   check_amt = 00.00;
   total_balance = init_amt;
}

b.
   // balance is updated when a check is written
inline void checkbook::write_check(double input_amt)
{
   // subtract input amount from total balance
   total_balance = total_balance - input_amt;

}

c.
   // balance is updated when a deposit is made
inline void checkbook::make_deposit(double input_amt)
{
   // add input amount to total balance
   total_balance = total_balance + input_amt;
}

d.   //return the current balance
inline double checkbook::current_balance()
{
   return(total_balance);
}

b)
void main()
{
   // declare 2 checkbook objects     
   checkbook personal,business;
     

c)   // call open function to initialize valves. opening balance is $300.00
   personal.open(300.00);
  
   // call write_check function with $50.25 as function argument  
   personal.write_check($50.25);

   // call write_check function with $150.00 as function argument  
   personal.write_check($150.00);

   // call make_deposit function with $87.34 as function argument  
   personal.make_deposit($87.34);

   // print the resulting balance
   cout << "BALANCE: " << personal.current_balance();

d)
a. //  Revise the class declaration, use constructors.

class checkbook {

private:
   double deposit_amt;        // deposit amount
   double check_amt;       // amount to be written on check
   double total_balance;       // remaining balance after a transaction

public:
   void write_check(double input_amt);   // subtract from checkbook  
  
   void make_deposit(double input_amt);    // add to checkbook
  
   double current_balance();   // returns balance
}

// default constructor with no function arguments
checkbook::checkbook()
{
// initialize balance to zero
   total_balance=00.00;
}
// constructor with one function argument whihc is the initial amount
checkbook::checkbook(double init_amt)
{
// initialize balance to init_amt
   total_balance=init_amt;
}

b.

void main()

{
   // default constructor is invoked when object is created with no initial value
// parameterized constructor is invoked when object is created with initial value of 500.00
   checkbook business1, business2(500.00);
  
   // print the opening balance for business1 object
   cout << "BALANCE: " << business1.current_balance(); // Zero is printed


   // print the opening balance for business2 object
   cout << "BALANCE: " << business2.current_balance(); // 500.00 is printed
}  

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote