This is a continuation of Exercise 2 from Week 5 practical exercises. Use the two java files, Expenses.java and ExpensesDemo.java that you developed in Exercise 1 Week 5. Import the two java files into your week 6 project in Eclipse then:

  • Add the following data field to the Expenses class. Month - the name of the month for the expenses [a string]
  • Add accessor and mutator methods for this new data field to the Expenses class
  • Add a constructor to the Expenses class that takes a single argument (the name of the month) and sets all other data fields to 0
  • In the expensesDemo source code add Java code to do the following:
    • Obtain the name of the month for which expenses will be entered; instantiate an Expenses object (using the constructor you created in part c) for the month; enter sales and expenses data for each week of the month; display the month name, balance, the total of income, total of expenditure, and Keleven from the month's expense object.
    • Set up a loop so that multiple months data may be entered by the user (the following screen shot is an example execution of the program to assist your understanding of requirements). Note: for the purpose of this question there is no need to 'remember' all Expenses objects that are created, hence, an array is not needed.
Month Name: February
How many weeks in February? 4

February Sales & Expenditure week 1: 200 300
February Sales & Expenditure week 2: 300 450
February Sales & Expenditure week 3: 350 250
February Sales & Expenditure week 4: 275 275

For Month of February:
Balance:
$-150.00
Total Sales:
$1125.00
Total Expenses:
$1275.00
Keleven:
$150.00

Enter another month's data? Y/N Y

Month Name: March
How many weeks in March? 5

March Sales & Expenditure week 1: 200 200
March Sales & Expenditure week 2: 150 150
March Sales & Expenditure week 3: 350 400
March Sales & Expenditure week 4: 400 350
March Sales & Expenditure week 5: 225 200

For Month of March:
Balance: $25.00
Total Sales: $1325.00
Total Expenses: $1300.00
Keleven: $0.00
Enter another month's data? Y/N N
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.