The goal of this lab is to write a java program that acts as a way to store payments, depending on whether a customer pa

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

The goal of this lab is to write a java program that acts as a way to store payments, depending on whether a customer pa

Post by answerhappygod »

The goal of this lab is to write a java program that acts as a
way to store payments, depending on whether a customer pays with
cash or credit card.
1. Define a class called Payment that contains a private
variable of type double that stores the amount of the payment.
Include the appropriate getters and setters. Also, create a method
called paymentDetails that outputs a sentence to describe the
payment amount.
2. Define a class named CashPayment that extends the Payment
class. This class should redefine the paymentDetails method to
indicate that the payment is made in cash.
3. Define a class named CreditCardPayment that contains private
variables for the name on the card, the expiration date, and the
credit card number. Create appropriate getters and setters. Again,
redefine a paymentDetails method to include all credit card
information in the print out.
4. In your MainClass, create two CashPayment objects and two
CreditCardPayment objects with different values and call
paymentDetails for both. A sample run is below:
You paid $500. 0 I n c an s h .
You p a i d $800 . 0 i n c a s h .
You p a i d $650 . 0 t o be c h a r g e d t o Joey on c a r d 8
7 2 4 9 1 2 4 7 2 w i t h e x p i r a t i o n 1 2 / 0 9 .
You p a i d $100 . 0 t o be c h a r g e d t o Kara on c a r d 9
8 3 4 2 3 9 4 2 3 w i t h e x p i r a t i o n 5 / 2 3 .
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply