Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write an Expenses class that stores the monthly balance [a double], total of income (total of all sales or incoming moneys) for the current
Write an Expenses class that stores the monthly balance [a double], total of income (total of all sales or incoming moneys) for the current month [a double], total of expenditure (total of all outgoing money) for the current month [a double]. The class should have a set method for the balance data field and get methods for all data fields. The class should also have methods for adding the amount of a sale to the balance, subtracting the amount of an expenditure from the balance, accumulating the total of all incoming money in the month, accumulating the total of expenditure in the month. The class will also need a method to calculate Keleven to be able to balance the expenses if necessary (see note below). What is Keleven? Even though Kevin wants the balance to be 0 or positive at the end of the month he recognises that sometimes he may have essential purchases at different times (for example, pizza, hot dogs or pie) which means he may spend more than he earns from the ice-cream sales (ie, the balance will be less than 0). To balance the accounts in his daytime job at Dunder Mifflin Kevin employs a unique accounting method he calls a Keleven; he believes that a Keleven can be used in your program to balance his expenses each month when needed. Keleven is the amount added to the balance at the end of the month to ensure that the balance becomes 0. Write a program to test the Expenses class by: creating an expense object for the current month with a starting balance of $0, entering sales and expenditures on the expense object for each week in the month. At the end of the month display the balance, the total of income, total of expenditure, and Keleven from the expense object. Ensure that appropriate validation of user input is implemented. Figures 3, 4, 5 represent example executions of the program to assist you understand what the program needs to do: How many weeks this month? 4 Sales & Expenditure for week 1: 200 300 Sales & Expenditure for week 2: 300 450 Sales & Expenditure for week 3: 350 250 Sales & Expenditure for week 4: 275 275 Month Balance: $-150.00 Total Sales: $1125.00 Total Expenses: $1275.00 Keleven: $150.00 Figure 3 How many weeks this month? 5 Sales & Expenditure for week 1: 200 200 Sales & Expenditure for week 2: 150 150 350 400 Sales & Expenditure for week 3: Sales & Expenditure for week 4: 400 350 Sales & Expenditure for week 5: 200 200 Month Balance: $0.00 Total Sales: $1300.00 Total Expenses: $1300.00 Keleven: $0.00 Figure 4 How many weeks this month? Sales & Expenditure for week 1: 300 200 Sales & Expenditure for week 2: 450 300 Sales & Expenditure for week 3: 250 350 Sales & Expenditure for week 4: 275 275 Month Balance: $150.00 Total Sales: Keleven: $1275.00 Total Expenses: $1125.00 $0.00 Figure 5
Step by Step Solution
There are 3 Steps involved in it
Step: 1
import javautil Expend class class Expend private double monthlyBalance private double totalIncome private double totalExpenditure public Expenddefaul...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started