Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Credit Card Class Write a class named CreditCard that has (at least) the following member variables: name. A String that holds the card holder's name.

image text in transcribed
Credit Card Class Write a class named CreditCard that has (at least) the following member variables: name. A String that holds the card holder's name. cardNumber. A field that holds the credit card number. balance. A double that stores the current credit card balance. spending Limit. A double that stores the spending limit of the card holder. additional fields that you can think of . In addition, the class should have (at least) the following member methods: Constructor. The constructo 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. r should accept the card holder's name and card number and .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 customer's spending limit. increaseSpendingLimit. This method should increase the spending limit by $50 each time it is called. pay Bill. 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. ws the user to Demonstrate the class in a program that creates a CreditCard object and all change and view the state of the credit card with a menu driven program. View Card Information. 2. 1. 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 cl 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. ass. All

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

Intranet And Web Databases For Dummies

Authors: Paul Litwin

1st Edition

0764502212, 9780764502217

More Books

Students also viewed these Databases questions

Question

7. What decisions would you make as the city manager?

Answered: 1 week ago