Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Question! (a) Create a struct called Account (b) Give it a single member variable balanceInPennies. This should be of type int (c) (You may

C++ Question!

image text in transcribed

(a) Create a struct called Account (b) Give it a single member variable balanceInPennies. This should be of type int (c) (You may want to ignore this until after Monday.) Give it two constructors 1. i. The first should have no parameters, and initialize balanceInPennies to be o ii. The second should should have one parameter, and initialize balanceInPennies ac- cordingly. (d) Give it three member functions i. query should take no parameters and return the balanceInPennies ii. deposit should have one parameter of type unsigned int, and should deposit this amount to the balance iii. withdraw should have one parameter of type unsigned int, and should withdraw this amount from the balance. However, if there is not enough money in the account, it should print "5 dollar penalty charged for attempting to withdraw more than available, and make the appropriate deduction The first two are shorter, so define them in the struct. The last is longer, so define it after the struct (You may want to ignore this until after Monday...) Make your functions const correct Are you changing member variables? 2. (a) Create a struct called Bank. (b) Give it two member variables checking and saving. They should both be of type Account, the struct you made in the first question. (c) (You may want to ignore this until after Monday.) Give it two constructors i. The first should have no parameters, and initialize both accounts to be zero ii. The second should should have two parameters, and initialize checking and saving accordingly (d) Declare four member functions void deposit (unsigned int amount, char account) void withdraw(unsigned int amount, char account); void transfer (unsigned int amount, char from, char to); void printBalances) const; 21 Define them accordingly with c and s standing for checking and saving, respectively For transfer, to deal with the case when someone is attempting to withdraw more than available, you could edit Account: :withdraw to return a bool which says whether or not a transfer was made

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

AutoCAD Database Connectivity

Authors: Scott McFarlane

1st Edition

0766816400, 978-0766816404

More Books

Students also viewed these Databases questions