Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I need help changing this java code from scanner input to ONLY JOptionPane for input and output import java.util.Scanner; public class RealEstateImplementation { public static
I need help changing this java code from scanner input to ONLY JOptionPane for input and output import java.util.Scanner; public class RealEstateImplementation { public static void main(String args[]) { //make a scanner object to take user input Scanner input=new Scanner(System.in); // make a RealEstate object with default constructor RealEstate obj1=new RealEstate(); // make a RealEstate object with parametrized constructor RealEstate obj2=new RealEstate("Property Address" ,350.0, 200.0, 100.0, 20); // define variables to sum total total purchase price, toal Renovation price and total BreakEven Cost double TotalPurchasePrice=0.0,TotalRenovationCost=0.0, TotalBreakEvenCost=0.0; //loop for taking user input for(int i=1;i<=5;i++) { //take address input System.out.print("Enter the address for property "+i + " : "); String addr=input.nextLine(); obj1.setAddress(addr); //take property purchase price input System.out.print("Enter the purchase price for property "+i + " : "); double pp=input.nextDouble(); obj1.setPurchasePrice(pp); TotalPurchasePrice+=pp; //take renovation cost input System.out.print("Enter the Renovation cost for property "+i + " : "); double rc=input.nextDouble(); obj1.setRenovationCost(rc); TotalRenovationCost+=rc; //take property tax input System.out.print("Enter the Tax for property "+i + " : "); int tax=input.nextInt(); input.nextLine(); obj1.setPropertyTax(tax); // calculate breakeven cost TotalBreakEvenCost+= obj1.getBreakEvenCost(); //display property information String display=obj1.toString(); System.out.println(display+ " "); } // calculate averages double averagePurchasePrice = TotalPurchasePrice /5; double averageRenovationCost = TotalRenovationCost /5; double averageBreakEvenCost = TotalBreakEvenCost /5; //prints all the averages 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); } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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