Question: write a read me file contsining instructions for how to compile the and run the following software. import java.util.Scanner; import java.util.ArrayList; import java.util.Collections; import java.util.List;
write a read me file contsining instructions for how to compile the and run the following software.
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
creating an abstract class of Expenses
abstract class Expense
protected String name;
protected double amount;
constructor of expenses
public ExpenseString name, double amount
this.name name;
this.amount amount;
abstract method that will be used to calculate expenses
public abstract double totalExpenses;
public double getAmount
return amount;
public String toString
return name : amount;
classes that extend abstract Expense to get different expenses
class Groceries extends Expense
public Groceriesdouble amount
superGroceries amount;
@Override
public double totalExpenses
return amount;
class Utilities extends Expense
public Utilitiesdouble amount
superWater and lights", amount;
@Override
public double totalExpenses
return amount;
class Travel extends Expense
public Traveldouble amount
superTravelling cost amount;
@Override
public double totalExpenses
return amount;
class Communication extends Expense
public Communicationdouble amount
superCellphone and Telephone", amount;
@Override
public double totalExpenses
return amount;
class otherExpenses extends Expense
public otherExpensesdouble amount
superOther Expenses", amount;
@Override
public double totalExpenses
return amount;
class for renring option
class Renting extends Expense
public Rentingdouble amount
superRenting amount;
@Override
public double totalExpenses
return amount;
class for buying the house option
final class Buying extends Expense
private final double purchasePrice;
private final double depositAmount;
private final double interestRate;
private final double loanPeriod;
public Buyingdouble purchasePrice, double depositAmount, double interestRate, double loanPeriod
superMonthly house repayment", ;
this.purchasePrice purchasePrice;
this.depositAmount depositAmount;
this.interestRate interestRate;
this.loanPeriod loanPeriod;
this.amount totalExpenses; setting the total of all expenses
calculating the monthly loan repayment and adding it to total expenses
@Override
public double totalExpenses
double loanAmount purchasePrice depositAmount;
double decimalInterestRate interestRate;
double periodInYears loanPeriod;
double totalLoanAmount loanAmountdecimalInterestRateperiodInYears;
double monthlyPayment totalLoanAmountloanPeriod;
return monthlyPayment;
setting up a class for car loan
class CarLoan extends Expense
private final String model;
private final String manufacturer;
private final double vehiclePurchasePrice;
private final double vehicleDeposit;
private final double vehicleInterestRate;
private final double insurancePremium;
private final double monthsToRepay;
public CarLoanString model,String manufacturer, double purchasePrice, double deposit, double interestRate, double insurancePremium, double monthsToRepay
superCar monthly payment", ;
this.model model;
this.manufacturer manufacturer;
this.vehiclePurchasePrice purchasePrice;
this.vehicleDeposit deposit;
this.vehicleInterestRate interestRate;
this.insurancePremium insurancePremium;
this.monthsToRepay monthsToRepay;
this.amount totalExpenses;
to calculate the monthly repayments for the car
@Override
public double totalExpenses
double principal vehiclePurchasePrice vehicleDeposit;
double monthlyInterestRate vehicleInterestRate ;
double periodOfPayment monthsToRepay;
double carLoanRepayment principalmonthlyInterestRateperiodOfPayment;
double monthlyCarPayment carLoanRepaymentmonthsToRepay;
double monthlyCarInstallment monthlyCarPayment insurancePremium; Total monthly cost loan repayment insurance premium
return monthlyCarInstallment ;
public class PartI
the main method
public static void mainString args
Scanner input new ScannerSystemin;
List expenses new ArrayList; storing expenses in an array
requesting the user to enter monthly gross salary and tax deductions
System.out.printlnEnter your gross monthly income: ;
double monthlyIncome input.nextDouble;
System.out.printlnEnter your estimated monthly tax deductions: ;
double deductedTax input.nextDouble;
asking the user if they want to buy or rent property
int propertyChoice ;
double livingCost ;
using do while to ensure that the program is only limmited to either buying or renting
do
System.out.printlnWould you like to rent or buy property? Enter for renting or for buying ;
propertyChoice input.nextInt;
if propertyChoice && propertyChoice
System.out.printlninvalid option selected. Please enter for renting or for buying";
while propertyChoice && propertyChoice ;
if propertyChoice
System.out.printlnEnter your monthly rental amount: ;
double rentAmount input.nextDouble;
expenses.addnew RentingrentAmount;
livingCost rentAmount;
else if propertyChoice
System.out.printlnEnter the house purchase price";
double purchasePrice input.nextDouble;
System.out.printlnEnter the deposit amount: ;
double depositAmount input.nextDouble;
System.out.printlnEnter the interest rate in percentage";
double interestRate input.nextDouble;
System.out.printlnEnter the loan period in months should be between and months;
double loanPeriod input.nextDouble;
Buying buying new BuyingpurchasePrice depositAmount, interestRate, loanPeriod;
expenses.addbuying;
livingCost buying.totalExpenses;
checking the likelihood of getting the loan
if buyingtotalExpensesmonthlyIncome
System.out.printlnWARNING: your monthly repayment is greater than onethird of your gross salary. Approval of your loan is unlikely";
asking the user to enter their monthly expenses
System.out.printlnEnter the amount of money spent on grocery monthly: ;
double groceryMoney input.nextDouble;
expenses.addnew GroceriesgroceryMoney;
System.out.printlnEnter the amount of money spent on water and Lights monthly: ;
double utilitiesMoney input.nextDouble;
expenses.addnew GroceriesutilitiesMoney;
System.out.printlnEnter the amount of money spent on travelling monthly: ;
double travelCost input.nextDouble;
expenses.addnew UtilitiestravelCost;
System.out.printlnEnter the amount of money spent on cellphone and telephone monthly: ;
double communicationMoney input.nextDouble;
expenses.addnew CommunicationcommunicationMoney;
System.out.printlnEnter the amount of money spent on any other expenses monthly: ;
double otherExpensesMoney input.nextDouble;
expenses.addnew otherExpensesotherExpensesMoney;
Ask the user if they want to buy a vehicle
System.out.printlnDo you want to buy a vehicle? Enter 'yes' or no: ;
String buyVehicle input.next;
double monthlyCarPayment ;
if buyVehicleequalsIgnoreCaseyes
System.out.printlnEnter the model of the vehicle: ;
String model input.next;
System.out.printlnEnter the make of the vehicle: ;
String manufacturer input.next;
System.out.printlnEnter the purchase price of the vehicle: ;
double vehiclePurchasePrice input.nextDouble;
System.out.printlnEnter the total deposit: ;
double vehicleDeposit input.nextDouble;
System.out.printlnEnter the interest rate as a percentage: ;
double vehicleInterestRate input.nextDouble;
System.out.printlnEnter the period of payment in months ;
double monthsToRepay input.nextDouble;
System.out.printlnEnter the estimated monthly insurance premium: ;
double insurancePremium input.nextDouble;
CarLoan carLoan new CarLoanmodelmanufacturer, vehiclePurchasePrice, vehicleDeposit, vehicleInterestRate, insurancePremium, monthsToRepay; years months
expenses.addcarLoan;
monthlyCarPayment carLoan.totalExpenses;
calculating the net income, total expenses and available money
double netIncome monthlyIncome deductedTax;
double totalExpenses ;
for Expense expense : expenses
totalExpenses expense.totalExpenses;
if totalExpenses monthlyIncome
System.out.printlnWarning: Your total expenses exceed of your gross income.";
Display the total expenditure in descending order by value
Collections.sortexpensesa b Double.comparebtotalExpenses atotalExpenses;
System.out.printlnExpenses in descending order by value:";
for Expense expense : expenses
System.out.printlnexpensetoString;
Display the breakdown of expenses
System.out.println
Expenses Breakdown
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
