Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program to create and use gift cards. Write a separate class to represent a gift card, and name it appropriately. A gift card

Write a program to create and use gift cards.

Write a separate class to represent a gift card, and name it appropriately.

A gift card can only be given a value when it is instantiated.

A gift card cannot have a negative balance.

A gift card has a debit method with a double parameter, which should reduce the current balance of the gift card by the amount of the parameter or the total amount of the current balance, whichever is less, and return the amount that the balance was reduced.

A gift card has a getBalance method which will return the current balance of the gift card.

Write a driver program to input an amount from the user and instantiate a gift card for that amount, then input amounts of purchases until the balance of the gift card is $0. For the last purchase, the remaining amount due should be reported.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions