Question: I Need help checking my Java code and please fix it if possible Here is the Scenario: You have been hired as an associate for

I Need help checking my Java code and please fix it if possible

Here is the Scenario:

You have been hired as an associate for a Real Estate Portfolio company specializing in renovations. Your first task is to create a program that calculates the break-even cost for each property under their portfolio. The Real Estate Portfolio currently has 5 properties under their portfolio. Each property has the following characteristics: an address, purchase price, and a renovation cost.

At minimum, each property must have an address. The purchase price of the property must be greater than zero and the renovation cost should be no greater than the purchase price. In order to calculate a propertys break-even cost, you must enter the propertys tax percentage for the area (for example, the tax percentage could be 5%). The tax percentage can only be as high as 33%. Use the below formula to calculate the break-even cost for each property.

Break-Even Cost Formula Purchase Price + Renovation Cost + (Purchase Price * (1 + tax percentage))

Your object-oriented application must use a data definition class to model each Property with an implementation class requesting each properties characteristics and the tax percentage. The data definition class should track the address, purchase price, and renovation cost. Accessors and mutators must be created for all instance variables.

With a completed data definition class, your implementation class should only define 1 property object, but be reused to instantiate each property. Your object-oriented application will gather the properties address, purchase price, renovation cost, and that propertys tax percentage. The application should then print out well-formatted report containing the property address, purchase price, renovation cost, and break-even cost. Then, the application should repeat this process until all 5 properties have been entered. Once all properties have been entered, print out a final well-formatted message stating the average purchase price, renovation cost, and break-prices for all the properties.

Here is my code below :

This is the Implementation

import java.util.Scanner; public class RealEstateImplementation { public static void main(String args[]) { Scanner input=new Scanner(System.in); RealEstate obj1=new RealEstate(); RealEstate obj2=new RealEstate("Property Address" ,350.0,200.0,100.0,20); double averagePurchasePrice=0.0,averageRenovationCost=0.0, averageBreakEvenCost=0.0; for(int i=1;i<=5;i++) { System.out.println("Enter the address for property "+i); String addr=input.nextLine(); obj1.setAddress(addr); System.out.println("Enter the purchase price for property "+i); double pp=input.nextDouble(); obj1.setPurchasePrice(pp); averagePurchasePrice+=pp; System.out.println("Enter the Renovation cost for property "+i); double rc=input.nextDouble(); obj1.setRenovationCost(rc); averageRenovationCost+=rc; System.out.println("Enter the Tax for property "+i); int tax=input.nextInt(); obj1.setPropertyTax(tax); obj1.Calculate(); averageBreakEvenCost+=breakEvenCost; String display=obj1.toString(); System.out.println(display); } System.out.println("The average Purchase Price for properties ="+averagePurchasePrice); System.out.println("The average Renovation Cost for properties="+averageRenovationCost); System.out.println("The average Break price for properties="+averageBreakEvenCost); } }

This is the Class

// Defines class RealEstate public class RealEstate { // Instance variables to store property information private String address; private double purchasePrice; private double renovationCost; private double breakEvenCost; private int propertyTax; // Default constructor RealEstate() { this.address = ""; this.purchasePrice = 1; this.renovationCost = breakEvenCost = 0.0; this.propertyTax = 0; } // Parameterized constructor RealEstate(String address, double purchasePrice, double renovationCost, double breakEvenCost, int propertyTax) { this.address = address; this.purchasePrice = purchasePrice; this.renovationCost = renovationCost; this.propertyTax = propertyTax; } // Setter methods public void setAddress(String address) { this.address = address; } public void setPurchasePrice(double purchasePrice) { // Checks if purchase price is less than or equals to 0 if(purchasePrice <= 0) { throw new IllegalArgumentException(" ERROR: Purchase price must be greater than 0."); } this.purchasePrice = purchasePrice; } public void setRenovationCost(double renovationCost) { // Checks if renovation cost is greater than purchase price if(renovationCost > purchasePrice) { throw new IllegalArgumentException(" ERROR: Renovation cost must be less than " + "Purchase price."); } this.renovationCost = renovationCost; } void setPropertyTax(int propertyTax) { // Checks if property tax is less than 33% if(propertyTax > 33) { throw new IllegalArgumentException(" ERROR: Property tax must be less than or " + "equals to 33%."); } this.propertyTax = propertyTax; } // Method to accept data from user public String getAddress() { return this.address;} public double getPurchasePrice() { return this.purchasePrice;} public double getRenovationCost() { return this.renovationCost;} public double getPropertyTax() { return this.propertyTax;} // Method to calculate break even cost public void Calculate() { breakEvenCost= purchasePrice + renovationCost + (purchasePrice * (1 + propertyTax)); } // Overrides toString method to return property information public String toString() { return " Address: " + address + " Property Purchase Price: $" + purchasePrice + " Property Renovation Cost: $" + renovationCost + " Property Tax: " + propertyTax + " Break Even Cost: $" + breakEvenCost; } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!