lease help asap, having trouble figuring this out and it is due tonight. Write the abstract super class Transaction, and two of its subclasses, Payment and Sale (you do not need to supply any comments other than your name). I. Write an abstract superclass encapsulating a Transaction:            The Transaction super class has an instance variable representing the customers name, and 3 methods:   an overloaded constructor, a toString() method that returns a message including the name of the customer, and an abstract method called calculateAmount()which will be implemented in your subclasses.  II. Write a non-abstract subclass that inherits from the Transaction class encapsulating a Payment:              The Payment class has instance variable representing the payment amount received and 3 methods.   It has an overloaded constructor, a toString() method that returns a message including customers name, the name of the class Payment, and the payment amount, an non-abstract class called calculateAmount() which returns the payment amount.  III. Write a second non-abstract subclass that inherits from the Transaction class encapsulating a Sale:               The Sale class has 2 instance variables representing the price and quantity of the sale and 3 methods.   It has an overloaded constructor, a toString() method that returns a message including the customers name, the name of the class Sale, plus the price and quantity of the sale. calculateAmount() which returns the total amount of the sale (quantity times price, with an eight and a-half percent sales tax).    IV. Write a client program which instantiates 3 objects of your subclasses and stores them in an array of Transaction objects or an ArrayList of Transaction objects. Your client program should process your array or ArrayList calling the toString()followed by the calculateAmount( ) methods which will print the contents of the array.   Sample Program Output: Bob Jones      Sale       19.95      1 Total Amount: $ 21.65 Jane Doe       Payment    150.87 Total Amount: $ 150.87 Jack Torance   Sale        50.00      2 Total Amount: $  108.50

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

JAVA

Please help asap, having trouble figuring this out and it is due tonight.

Write the abstract super class Transaction, and two of its subclasses, Payment and Sale (you do not need to supply any comments other than your name).

I. Write an abstract superclass encapsulating a Transaction:

           The Transaction super class has an instance variable representing the customers name, and 3 methods:

 

  • an overloaded constructor,
  • a toString() method that returns a message including the name of the customer,
  • and an abstract method called calculateAmount()which will be implemented in your subclasses.

 II. Write a non-abstract subclass that inherits from the Transaction class encapsulating a Payment:

             The Payment class has instance variable representing the payment amount received and 3 methods.

 

  • It has an overloaded constructor,
  • a toString() method that returns a message including customers name, the name of the class Payment, and the payment amount,
  • an non-abstract class called calculateAmount() which returns the payment amount.

 III. Write a second non-abstract subclass that inherits from the Transaction class encapsulating a Sale:

              The Sale class has 2 instance variables representing the price and quantity of the sale and 3 methods.

 

  • It has an overloaded constructor,
  • a toString() method that returns a message including the customers name, the name of the class Sale, plus the price and quantity of the sale.
  • calculateAmount() which returns the total amount of the sale (quantity times price, with an eight and a-half percent sales tax).

 

 IV. Write a client program which instantiates 3 objects of your subclasses and stores them in an array of Transaction objects or an ArrayList of Transaction objects. Your client program should process your array or ArrayList calling the toString()followed by the calculateAmount( ) methods which will print the contents of the array.

 

Sample Program Output:

Bob Jones      Sale       19.95      1
Total Amount: $ 21.65

Jane Doe       Payment    150.87
Total Amount: $ 150.87

Jack Torance   Sale        50.00      2
Total Amount: $  108.50

Expert Solution
steps

Step by step

Solved in 5 steps with 1 images

Blurred answer
Knowledge Booster
Software Development
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education