Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Credit Card Class Write a class named CreditCard that has the following member variables: name. A String that holds the card holders name. cardNumber. A

Credit Card Class Write a class named CreditCard that has the following member variables:

name. A String that holds the card holders name.

cardNumber. A field that holds the credit card number.

balance. A double that stores the current credit card balance.

spendingLimit. A double that stores the spending limit of the card holder.

additional fields that you can think of. In addition, the class should have the following member methods

: Constructor. The constructor should accept the card holders name and card number and assign these values to the object's corresponding member variables. The constructor should initialize the spending limit to $2,000 and the balance to $0.

Accessors. Appropriate accessor methods should be created to allow values to be retrieved from an object's member variables.

purchase. This method should add the amount specified as a parameter to the balance member variable each time it is called, assuming the purchase does not cause the balance to exceed the customers spending limit.

increaseSpendingLimit. This method should increase the spending limit by $50 each time it is called.

payBill. This method should reset the balance to 0.

toString. to render the state of a CreditCard as a String. Input validation: Whenever a credit card number is modified, verify that it is of reasonable length. Demonstrate the class in a program that creates a CreditCard object and allows the user to change and view the state of the credit card with a menu driven program.

1. View Card Information.

2. Purchase an Item: ask the user the purchase amount and increase the card balance accordingly.

3. Pay Bill: call payBill method to set the balance to 0.

4. Increase Spending Limit: ask the user how much the spending limit should be, and call the increaseSpendingLimit method the appropriate number of times.

Keep in mind: input and output should not be performed directly in the CreditCard class. All input and output to the user should be done in the main method (or other methods that are in a separate class) to increase flexibility of the classes we will design later on in this project.

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

Authors: David Kroenke, David J. Auer

3rd Edition

0131986252, 978-0131986251

More Books

Students also viewed these Databases questions

Question

What attracts you about this role?

Answered: 1 week ago

Question

How many states in India?

Answered: 1 week ago

Question

HOW IS MARKETING CHANGING WITH ARTIFITIAL INTELIGENCE

Answered: 1 week ago

Question

Different types of Grading?

Answered: 1 week ago