Question 1

You are tasked to design an application to keep track of sales for your company. Sales should be tracked for two types of accounts: supplies and services.

Complete the following:

  • Create a UML class diagram for the Account inheritance hierarchy. Your subclasses should be Supplies and Services.
  • All sales accounts will have an account ID (accountId).
  • You will need attributes to keep track of the number of hours (numberOfHours) and rate per hour of services provided (ratePerHour).
  • You should also keep track of the number of items sold (numberOfItems) and the price per item for the sold supplies (pricePerItem).
  • All classes should have a constructor.
  • Add getters and setters to all of your classes.
  • Override the method toString in all 3 classes.
  • Add a method to calculate the sales in each class [calculateSales()].

Question 2

In NetBeans, implement your account class diagram created earlier.

Complete the following:

  • Your Java project should include 3 classes: Account.java, Services.java, and Supplies.java.
  • There should be implemented constructors for each class.
  • The toString() method should be overridden to provide a readable string representation of each object.
  • Getters and setters need to be implemented to enforce data hiding.
  • The calculateSales() method should be implemented for all classes Consider having the calculateSales() as an abstract method for the Abstract Account class.
  • In addition, you need to create a test class companySales.java that tests each subclass's constructor, toString(), and computeSales().
  • You need to create an instance of each subclass.
  • Input can be hard-coded or entered by the user.
  • You need to call the method calculateSales() for each instance.
  • You need to print each class info using its method toString().
  • Code should be fully commented.
  • Program flow should be logical.

Question 3

What type of relationship is composition commonly called and why.

Explain the "catch or declare" requirement of Java exception handling.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.