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.
GiftCard
amount: double
GiftCard(double)
buybook(double): void
amountRemaining(): double
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

Fundamentals Of Database Management Systems

Authors: Mark L. Gillenson

2nd Edition

0470624701, 978-0470624708

More Books

Students also viewed these Databases questions