Question

Book: C++ Programming From Problem Analysis to Program Design Chapter: 13 Problem Number: 14 Program Please...

Book: C++ Programming From Problem Analysis to Program Design
Chapter: 13
Problem Number: 14 Program

Please help to clarify this problem. It would be greatly appreciated.

Thanks
0 0
Add a comment Improve this question Transcribed image text
Answer #1
Dear,
Here is the solution for BankAccount...

//Header section

#include

using namespace std;

//Base class BankAccount

class BankAccount

{

//Data members

public:

       int accountNumber;

       double balance;

public:

          //Constructor

       BankAccount(int ano,double bal)

       {

              accountNumber=ano;

              balance=bal;

       }

       BankAccount() { }

public:

     //Accessor methods for getting balance

     double getBalance()

       {

             return(balance);

       }

     //Accessor methods for getting account number

       int getAccountNumber()

       {

              return(accountNumber);

       }

        //Mutuator method to set balance

        void setBalance(double amount)

       {

              balance=amount;

       }

        //Setting account number

        void setAccountNumber(int ano)

       {

              accountNumber=ano;

       }

        //show account information

       void virtual showAccountInfo()

       {

              cout<<"Account Number :"<

              cout<<"Account Balance:"<

       }

        //function to perform deposit

       double virtual depositAmount(double damount)

       {

             balance=balance+damount;

              return(balance);

       }

        //withdrawl amount

       double virtual withDrawAmount(double wamount)

       {

             balance=balance-wamount;

              return(balance);

       }

};//End of class


/***************************************

Checking Account class which is derived

from BankAccount.

****************************************/

class CheckingAccount : BankAccount

{

     //Data members

       double interest;

       double minBal;

       double serviceCharge;

public://Constructore

       CheckingAccount(int _ano,double _amount,double _interest):BankAccount(_ano,_amount)

       {

              interest=_interest;

              minBal=500;//By default

       }

        //To set interest rate

       void setInterestRate(double irate)

      {

              interest=irate;

       }

        //to get interest rate

       double retrieveInterestRate()

       {

              return(interest);

       }

        //to set minimum balance

       void setMinBal(double mbal)

       {

              minBal=mbal;

       }

        //To get minimum balance

       double retrieveMinBal()

       {

              return(minBal);

       }

        //To set service charge

       void setServiceCharge(double scharge)

       {

             serviceCharge=scharge;

       }

        //To get service charge

        double retrieveServiceCharge()

       {

              return(serviceCharge);

       }

        //To perform deposit

        //overriding base class function

       double depositAmount(double damount)

       {

             balance=balance+damount;

              return(balance);

       }

        //to perform withdraw

        //overriding base class function

       double withDrawAmount(double wamount)

       {

         //Checking for account have sufficient balance or not

             if(check())

                    balance=balance-wamount;

              else

                     cout<<"you have in sufficient balance"<

              return(balance);

       }

        //Check function for verifying balance

       bool check()

       {

             if(balance

                    return(false);

              else

                     return(true);

       }

        //To display account information

       void showAccountInfo()

       {

             cout<<"Account Number :"<

            cout<<"Account Balance:"<

       }

};//End of class

/***************************************

SavingAccount class which is derived

from BankAccount.

****************************************/

class SavingAccount:BankAccount

{

     //data member

       double minBal;

public:

          //Constructor

       SavingAccount(int _ano,double _amount):BankAccount(_ano,_amount)

       {

              minBal=500;

       }

         //to perform deposit

        //overriding base class function

       double depositAmount(double damount)

       {

              balance=balance+damount;

              return(balance);

       }

         //to perform withdraw

        //overriding base class function

        double withDrawAmount(double wamount)

       {

              if(check())

                     balance=balance-wamount;

              else

                     cout<<"you have in sufficient balance"<

              return(balance);

       }

        //Setting minimum balance

       void setMinBal(double mbal)

       {

              minBal=mbal;

       }

        //Checking for account sufficiency

       bool check()

       {

              if(balance

                     return(false);

              else

                     return(true);

       }

        //Showing account information

       void showAccountInfo()

       {

              cout<<"Account Number :"<

              cout<<"Account Balance:"<

       }

};//End of class

/*Main function to test above classes*/

int main()

{

        //Declaring local variables

        double amount;

       int choice;

        //Displaying menu choices

       do

       {

       cout<<"Create an Account"<

       cout<<"1 Checking Account"<

       cout<<"2 Saving Account"<

       cout<<"3 Exit"<

        //reading choice

       cin>>choice;

        //if checking account

       if(choice==1)

       {

          cout<<"enter account number";

        int ano;

        cin>>ano;

        cout<

        double obal;

        cin>>obal;

        double irate;

        cout<

        cin>>irate;

        CheckingAccount obj(ano,obal,irate);

        int ch;

        do

        {

              //ask choice of operations

            cout<<"1 Deposit"<

            cin>>ch;

              //Perform selected operation

            switch(ch)

            {

            case 1:

                    cout<<"Enter amount";

                    cin>>amount;

                    double damount;

                    damount=obj.depositAmount(amount);

                    cout<<"Available balance: "<

                    break;

            case 2:

                    cout<<"Enter amount";

                    cin>>amount;

                    double wamount;

                            wamount=obj.withDrawAmount(amount);

                    cout<<"Available balance: "<

                    break;

            case 3:

                     obj.showAccountInfo();

                     break;

            }//End of switch

         }while(ch!=4);

       }//end of if

       

//If choice is savings account

else if(choice==2)

{

//reading needed information

    cout<<"enter account number";

   int _ano;

    cin>>_ano;

    cout<

    double _obal;

    cin>>_obal;

    double _irate;

    cout<

    cin>>_irate;

     //Creating object for savings account

    SavingAccount sObj(_ano,_obal);

    int _ch;

    do

    {

        cout<<"1 Deposit"<

        cin>>_ch;

        switch(_ch)

        {

        case 1:

                cout<<"Enter amount";

                   cin>>amount;

                   double _damount;

                   _damount=sObj.depositAmount(amount);

                   cout<<"Available balance: "<<_damount;

                   break;

        case 2:

                cout<<"Enter amount";

                cin>>amount;

                double _wamount;

                _wamount=sObj.withDrawAmount(amount);

                cout<<"Available balance: "<<_wamount;

                break;

        case 3:

                sObj.showAccountInfo();

                break;

        case 4:break;

        default:cout<<"invalid choice";break;

        }//End of switch

    }while(_ch!=4);

   }//End of else

}while(choice!=3);

}//End of main

Sample output:
Hope this will help you...
Add a comment
Know the answer?
Add Answer to:
Book: C++ Programming From Problem Analysis to Program Design Chapter: 13 Problem Number: 14 Program Please...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I am trying to complete Chapter 9 exercise 9 in C# Programming: From Problem Analysis to...

    I am trying to complete Chapter 9 exercise 9 in C# Programming: From Problem Analysis to Program Design. I have both first name and last name textboxes, an account number textbox, and an initial balance textbox. I need to make error messages when the user doesnt enter their info, but can't figure out the if statements that i need to use. What would you suggest? Thanks

  • help C programming Write a program that solves the problem described in Chapter 5 problem number...

    help C programming Write a program that solves the problem described in Chapter 5 problem number 5.39 from the text. A screen capture of the problem statement is given below: Example: This program finds the greatest common divisor of two positive whole numbers. Enter your first positive whole number: 324 Enter your second positive whole number: 42 The greatest common divisor of 324 and 42 is 6.

  • From: Java Programming: From Problem Analysis to Program Design, 5th ed. Ch. 9, page 636, Problem...

    From: Java Programming: From Problem Analysis to Program Design, 5th ed. Ch. 9, page 636, Problem Exercise 12: Jason, Samantha, Ravi, Sheila, and Ankit are preparing for an upcoming marathon. Each day of the week they run certain miles and write them into a notebook. At the end of the week, they would like to know the number of miles run each day, the total miles for the week, and average miles run each day. Write a program to help...

  • Use Dec-C++ compiler Problem 13, Chapter 8 Programming Exercises 8.3 8.3. Write a program CHECKBOOK that...

    Use Dec-C++ compiler Problem 13, Chapter 8 Programming Exercises 8.3 8.3. Write a program CHECKBOOK that prompts the user for an amount and either + or -. If the user enters +, then balance, an extern variable, is incremented by the amount. If the user enters -, then balance is decremented by the amount. Two functions, deposit and withdraw, perform the updating operations.

  • Create a design document for a program that will take a number from the user and...

    Create a design document for a program that will take a number from the user and convert it to IEEE single precision format. The program displays the IEEE representation (Single precision) of the number entered by the user. PLEASE ADD THE PSEUDOCODE AND CODE WITH C PROGRAMMING

  • File Encryption and Decryption chapter 9 programming exercise #3 Design and write a python program to...

    File Encryption and Decryption chapter 9 programming exercise #3 Design and write a python program to successfully complete chapter 9 programming exercise #3. File Encryption and Decryption Write a program that uses a dictionary to assign “codes” to each letter of the alphabet. For example: codes = { ‘A’ : ‘%’, ‘a’ : ‘9’, ‘B’ : ‘@’, ‘b’ : ‘#’, etc . . .} Using this example, the letter A would be assigned the symbol %, the letter a would...

  • Please help me this problem. Provide the design and codes with pictures also separate answer Than...

    Please help me this problem. Provide the design and codes with pictures also separate answer Thank you Random Number File Reader This exercise assumes you have completed Programming Problem 13, Randorm Number File Writer. Create another application that uses an OpenFileDialog con- trol to let the user select the file that was created by the application that you wrote for Problem 13. This application should read the numbers from the file, display the numbers in a ListBox control, and then...

  • Please help me on solution of this problem. Thanks Compute design effect(d2) for the estimate prevalence...

    Please help me on solution of this problem. Thanks Compute design effect(d2) for the estimate prevalence of cell phone users under the cluster sample design. N.B: Survey Methodology, 2nd edition by Robert M.Groves, page 143, problem 10(d). The answer of exercise 10 from the chapter 4(d) is not available on the solution manual for the textbook. 10) In a sample of a 10 clusters containing b 10 completed houschold inter- views each, the total number of persons and the total...

  • ============== C programming problem. Please read carefully and full answers, thank you. Write a simple c...

    ============== C programming problem. Please read carefully and full answers, thank you. Write a simple c program that would show the output for the corresponding series 12 +22 +32+...n2 input(n) output 2 14 91 285 6

  • It must be C++ Chapter 13 Programming Challenge 2: Employee Class. See instruction: Chapter 13 Programming...

    It must be C++ Chapter 13 Programming Challenge 2: Employee Class. See instruction: Chapter 13 Programming Challenge 2 Employee Class.pdf Program Template: // Chapter 13, Programming Challenge 2: Employee Class #include <iostream> #include <string> using namespace std; // Employee Class Declaration class Employee { private: string name; // Employee's name int idNumber; // ID number string department; // Department name string position; // Employee's position public: // TODO: Constructors // TODO: Accessors // TODO: Mutators }; // Constructor #1 Employee::Employee(string...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT