Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Database Concepts International Edition

Authors: David M. Kroenke

6th Edition International Edition

0133098222, 978-0133098228

More Books

Students also viewed these Databases questions