Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

We will use structs to represent bank accounts and money respectively, and write functions that allow us to interact with our accounts. Requirements: Name your

We will use structs to represent bank accounts and money respectively, and write functions that allow us to interact with our accounts.

Requirements:

Name your source code file program1.cpp

Create two structures and name the types Account and Money.

The Money struct has two variables. One represents how many dollars you have. The other represents how many cents you have.

The Account struct has three variables. A Money struct that will represent how much money is in the account One variable to represent the interest rate as a decimal value. The final variable will contain the name of the account. (Checking, Savings, CD, etc.)

Negative amounts of Money are stored by making both variables of the Money object negative

Use the following function prototypes Account createAccount() * The function shall prompt the user for an account name, interest rate, and starting balance in that order *

The prompts shall appear as follows: Lets set up your account. First, whats the name of the account? What is the interest rate of your [NAME] account? Finally, what is the starting balance of your [NAME] account? $ [NAME] shall be replaced with the name of the account * You may NOT assume that the name of the account contains only a single word *

You may assume the user will always type an interest rate as a decimal value (e.g., 0.05) * You may also assume that a positive and valid (whole number or no more than two decimal places) amount of money will be entered Account deposit(Account account, Money deposit) *

The function shall not accept negative amounts of money If a negative amount of money is attempted to be deposited, an error message will be displayed, and the original account will be returned *

A message shall be printed to the screen that takes the form $X.XX deposited into [NAME]. only if a successful deposit is made. The message appears on its own line [NAME] shall be replaced with the name of the account * The balance of the account shall be updated accordingly Money withdraw(Account &account, Money withdraw) *

The function shall not accept negative amounts of money If a negative amount of money is attempted to be withdrawn, an error message will be displayed, and a Money object equivalent to $0.00 will be returned * You may allow the account to be overdrawn, but by no more than $50.00 *

A message shall be printed to the screen that takes the form $X.XX withdrawn from [NAME]. whether or not a successful withdrawl is made. The message appears on its own line [NAME] shall be replaced with the name of the account * The balance of the account shall be updated accordingly void accrue(Account &account) *

A message shall be printed to the screen that takes the form At X.XX%, your [NAME] account earned $X.XX. The message appears on its own line [NAME] shall be replaced with the name of the account void print([SINGLE PARAMETER]) x2 * The function shall be overloaded to accept either a Money object or an Account object * The functions shall print ONLY the amount of money This means no extra phrases like You have blah blah *

The amount of money shall be printed with a $, a decimal point, and only 2 decimal digits * There shall be no extra whitespace before or after the amount of money when it is printed * Negative amounts of money shall be represented in the following manner: ($X.XX) A sample run of your program shall look like this: NOTE: Savings, Checking, & Roth IRA are the values of the Account data member name for each Account object

NOTE: All money values are printed using one of the overloaded print() functions x111x111:$ ./hw01 In Savings, you have $50.00. In Checking, you have $10.00. Lets set up your account. First, whats the name of the account? Roth IRA What is the interest rate of your Roth IRA account? 0.07\

Finally, what is the starting balance of your Roth IRA account? $555.55 In your Roth IRA, you have $555.55. $50.00 deposited into Savings You now have $100.00 in your Savings account. $14.99 withdrawn from Checking. Withdrew $14.99 for HBO Now, you now have ($4.99) At 7.00%, your Roth IRA account earned $38.89. You now have $594.44 in your Roth IRA. At 7.00%, your Roth IRA account earned $41.61. You now have $636.05 in your Roth IRA. An unexpected expense appears! $200.00 Attempting to withdraw from Savings. $150.00 withdrawn from Savings. Its not very effective. You now have ($50.00) in your Savings account. Attempting some bad withdraws and deposits Cannot make negative deposit. Cannot make negative withdrawl. 0.00 withdrawn fromm Roth IRA.

x111x111:$ ./hw01 You must use both overloads of the print() function in your main() function

Hints: The functions listed in the Requirements are required (shocker!), but you may find it useful to write other helper functions Converting a double to a Money object can cause rounding errors You may want to look up the round() function Converting an amount of money to an equivalent amount of pennies makes a lot of logical work go away Take note of what statements are required to be printed from within functions, the rest are printed in the main() function You can create a file that holds user inputs and use it to streamline your testing.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

When is the best time to practice psychological skills?

Answered: 1 week ago