Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Your program should work with the following test program, to produce the expected output shown below. Expected Output: Books bought successfully Books bought successfully Not

Your program should work with the following test program, to produce the expected output shown below.
Expected Output:
Books bought successfully
Books bought successfully
Not enough money in the card
Remaining balance: 9.0Create a class GiftCard that represents a gift card for the purchase of books online. It should have the following private
attribute:
amount - the amount of money on the card
and the following public methods:
GiftCard(double amount)- a constructor to initialize the card
void buyBook(double totalPrice)- records the purchase of books by decreasing the amount of money used for purchase
using this card and prints "Books bought successfully". Print an error message if the gift card does not have sufficient
amount to pay the totalPrice.
double amountRemaining()- returns the remaining amount of money in the gift card.
image text in transcribed

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

Next Generation Databases NoSQLand Big Data

Authors: Guy Harrison

1st Edition

1484213300, 978-1484213308

More Books

Students also viewed these Databases questions

Question

What is the difference between basic EPS and fully diluted EPS?

Answered: 1 week ago

Question

Th eir solution was to give me a long-distance number to call.

Answered: 1 week ago