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

Create a class named Account in a package named bank. This class should have the

ID: 667376 • Letter: C

Question

Create a class named Account in a package named bank. This class should have the following private fields:

A String object named firstName
A String object named lastname
An integer variable named age
A double variable named annualIncome

Each variable should only be accessible through getters and setters.

getFirstName, setFirstName
getLastName, setLastName
getAge, setAge
getAnnualIncome, setAnnualIncome

Your class should include a constructor that initializes each of the fields above. A no-argument constructor should not be provided.

Add the following public methods:

deposit – this method takes a double as an argument. The method must not allow any deposits less than a penny. If the deposit is less than a cent, an exception should be thrown indication an invalid amount. If the amount if valid, the amount should be added to the balance. The method should report the transaction.

withdraw – This method should take a double as an argument. The method must not allow any withdrawal amount greater than the balance or less than a penny. If the amount isn’t valid, an exception should be thrown stating so. If the amount is valid, the amount should be deducted from the account balance. The method should report the transaction.

getBalance – This method takes no arguments and should return the account holder’s balance and report the transaction.

getLoan – This method takes a double as an argument and should return a Boolean. Only a Boolean value should be returned. This method should not throw an exception, but should report the transaction. Loan approval is based on the following criteria:

·             No loans are made for less than $500 or greater than $500k

·             For a loan approval amount between $500 - $5000 inclusive, if the user is under 25 years of age, the annual income must be greater than $35k, otherwise the annual income must be greater than $30k.

·             For loan approval amount between $5000.01 - $10000 inclusive, if the user is under 25 years of age, the annual income must be greater than $55k, otherwise the annual income must be greater than $52k.

·             For loan approval for any amount greater than 10k, if the user is under 25 years of age, the annual income must be greater than 100k, otherwise the annual income must be greater than 90k.

Reporting

·             To report a transaction, your class should contain a private reference to a Transaction object. You should instantiate an instance of a Transaction object in your constructor. Your class should provide a public method named printAllTransactions that returns nothing and takes nothing. Your class’ method should then call the object’s printAllTransactions method.

Explanation / Answer

#include <iostream>
#include <string>
#include <iomanip>    

using namespace std;

class Bank
{
private:
              char firstname;
               char lastname;
               int age;
               double aninc; //annual income
        void set_firstname(char a);
        void set_lastname(char b);
        void set_age(int c);
        void set_aninc(double d);
        char get_firstname();
        char get_lastname();
        int get_age();
        double get_aninc();
Public:
       Account();
       void Deposit(double money);
       void Withdraw(double money);


};
#include "bank.h"

Account::Account()
{

void Account::Add(double money)
{
    balance += money;
}

void Account::Withdraw(double money)
{
    if(money > balance)
        balance += PENALTY_FEE;
    else
        balance -= money;
}


#include "bank.h"

Account::Account()

Void Account::Add(double money)
{
    balance += money;
}

void Account::Withdraw(double money)
{
    if(money > balance)
        balance += PENALTY_FEE;
    else
        balance -= money;
}


#include "bank.h"

void deposit(double, string);
void withdraw(double, string);
void printBalances();

int main()
{
    string accountChoice;
    int selection;
    double transaction = 0;

    // !!!!!!!!!!!!!!!!!!HAVE TO STILL COMPUTE INTEREST!!!!!!!!!!!!!!!!

    cout << fixed << showpoint << setprecision(2);

    do
    {
        cout << "Please make a selection:" << endl;
        cout << "1.) Deposit" << endl;
        cout << "2.) Withdraw" << endl;
        cout << "3.) Transfer" << endl;
        cout << "4.) Print balances" << endl;
        cout << "5.) Quit" << endl;
        cin >> selection;

        if(selection == 1)
        {
            cout << endl << "Please select the account you would like to perform operations on(S or C):" << endl;
            cin >> accountChoice;
            cout << endl << "Please enter the amount to be deposited:" << endl;
            cin >> transaction;
            cout << endl;

            deposit(transaction, accountChoice);
        }

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