Question: C++ Wallet flashdrive Following the class diagram shown below, create the class Wallet. A Wallet represents a carrier of bills and coins. You use your

C++ Wallet flashdrive

Following the class diagram shown below, create the class Wallet. A Wallet represents a carrier of bills and coins. You use your wallet to pay for things, which reduces the balance held inside. When you visit an ATM, you can fill it back up with cash again. A sample driver for this class is shown below. You should probably make a more thorough driver to test your class better. I will have my own driver which will aim to exploit any possible edge cases.

Your submission should follow this organization:

main.cpp this is your driver file

wallet.h

wallet.cpp

Wallet

Wallet( ); Wallet( int d, int c ); int getDollars( ); int getCents( ); bool canPayFor( int dollarAmount, int centsAmount ); void payFor( int dollarAmount, int changeAmount ); void visitATMForCash( int dollarAmount );
int my_Dollars; int my_Cents;

Sample Driver Code

Wallet w; cout << "d:" << w.getDollars( ); cout << " c:" << w.getCents( ) << endl; w.visitATMForCash( 50 ); cout << "d:" << w.getDollars( ); cout << " c:" << w.getCents( ) << endl; if (w.canPayFor( 25, 35 )) { // you have enough to pay for it... w.payFor( 25, 35 ); cout << "buying $25.35 worth..." << endl; } cout << "d:" << w.getDollars( ); cout << " c:" << w.getCents( ) << endl; // this time you won't have enough money if (w.canPayFor( 25, 35 )) { // you have enough to pay for it... w.payFor( 25, 35 ); cout << "buying $25.35 worth..." << endl; } cout << "d:" << w.getDollars( ); cout << " c:" << w.getCents( ) << endl;

Sample Driver Output

d: 0 c: 0 d: 50 c: 0 buying $25.35 worth... d: 24 c: 65 d: 24 c: 65

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!