Answer to Question #5301 in C++ for sylvia

Question #5301
Use the following class definition:

class Account
{
public:
Account( char [], char, double); //constructor

void printAccount();
void changeBalance( double );

void setAcctType( char );

char getAcctType();
double getBalance();

private:
char name[50];
char acctType;
double balance;
};

Data Members

The data members for the class are:

name this holds the name of the account holder

acctType this holds 'S' for a savings account or 'C' for a checking account

balance this holds the account balance

Constructor

The constructor for the class should initialize the data members using the passed in arguments. It takes 3 arguments: a character array with the name of the account holder, a character that represents the type of account, and a double that holds the account balance. Use the setAcctType method to initialize the account type data member (this will help to guard against invalid initial values). If the changeBalance method is used to initialize the balance data member, don't forget to initialize the data member to 0 before calling the method.
Methods
void printAccount()

This method displays the account information. It takes no arguments and returns nothing. It should display the information as follows:

Name: Barney Rubble Checking Account Balance: $ 1234.56

or

Name: Fred Flintstone Savings Account Balance: $ 1234.56

void changeBalance( double amountToChange )

This method updates the balance of an account. It takes one argument: a double that represents the amount to change the account's balance. It returns nothing.

The argument will have a negative value if a withdrawl was made on the account or a positive value if a deposit was made to the account. In either case, simply add the passed in value to the current balance. After applying the update, if the resulting balance is less than 0, display a message that the account is overdrawn and that a fee of $10 will be added to the balance and then apply the fee to the balance.
void setAcctType( char newType )

This method changes an account type. It takes one argument: a character that represents the new account type. It returns nothing.

If the passed in account type is not 'S', 's', 'C', or 'c', display an error message and set the account type to 'C'. If the passed in account type is 'S', 's', 'C', or 'c', update the account type but *ONLY* use uppercase characters.
char getAcctType()

This method returns an account type. It takes no arguments.
double getBalance()

This method returns an account balance. It takes no arguments.
main()

In main(), create 5 Account objects. They should contain the values:

The first account should have your name, an account type of 'C', and a balance of 113019.77

The second account should have the name of your recitation TA, an account type of 'S', and a balance of 1234.50

The third account should have the name "Temperance Brennan", an account type of 's', and balance of 82.12

The fourth account should have the name "Seeley Booth", an account type of 'c', and a balance of 3869.00

The fifth employee should have the name "Zack Addy", an account type of 'C', and a balance of 71940.76

The rest of main() will include using the various methods on each of the 5 Account objects. Display a label similar to "The first Account object" before anything is outputted for each of the objects.

For the first account, display the account information, increase the account balance by 939.39, and display the account information once again.

For the second account, display the account information, decrease the account balance by 240.00, and display the account information once again.

For the third account, display the account information, change the account type to 'c', increment the account balance by 82000.12, and display the account information once again.

For the fourth account, display the account information, try to change the account type to an invalid value (the choice is up to you), decrease the account balance by 43321.98, display only the account balance, and display the account information once again.

For the fifth employee, display the account information, change the account balance by applying a withdrawl (the actual amount is up to you), display the account information, change the account balance by applying a deposit (the actual amount is up to you), and then display the account information once again.
1
Expert's answer
2011-11-24T08:45:53-0500
Dear Sylvia
Unfortunately, your question requires a lot of work and cannot be done for free.
Submit it with all requirements as an assignment here and we'll assist you.

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS