I'm working on this assignment and for the life of me I can not determine why I am getting a null in my output. I included my code below and would really appreciate some help and any criticism on my code.
Thanks!
Thanks!
Code:
import javax.swing.*;
public class Rental {
public static void main(String[] args) {
process();
}//end main method
public static void process(){
String output = "";
String input = "";
int count = 0;
input = JOptionPane.showInputDialog("Enter the number of houses that will be looked at: ");
count = Integer.parseInt(input);
String[] address = new String[count];
String[] city = new String[count];
String[] state = new String[count];
String[] property = new String[count];
int[] zip = new int[count];
int[] location = new int[count];
double[] inspectionCost = new double[count];
double[] repairCost = new double[count];
double[] totalCost = new double[count];
double totalExpense = 0;
int waterfront = 0;
int nonWaterfront = 0;
for(int i = 0; count > i; i++){
address[i] = JOptionPane.showInputDialog("Enter the street address: ");
city[i] = JOptionPane.showInputDialog("Enter the city: ");
state[i] = JOptionPane.showInputDialog("Enter the state: ");
input = JOptionPane.showInputDialog("Enter the zip code: "); zip[i] = Integer.parseInt(input);
input = JOptionPane.showInputDialog("Enter the cost of the inspection fee: \nWaterfront: 1 \nOther: 2"); location[i] = Integer.parseInt(input);
switch(location[i]){
case 1: inspectionCost[i] = 100; waterfront++; break;
case 2: inspectionCost[i] = 50; nonWaterfront++; break;
}//end switch statement
input = JOptionPane.showInputDialog("Enter the cost of repairs for the property: "); repairCost[i] = Double.parseDouble(input);
totalCost[i] = inspectionCost[i] + repairCost[i];
property[i] += address[i] + "\n" + city[i] + ", " + state[i] + " " + zip[i] + "\nTotal Cost of Rental Property: " + totalCost[i] + "\n\n";
output += property[i];
totalExpense += totalCost[i];
}//end for loop
output += "Total expected from all owners " + totalExpense + "\nNumber of waterfront rentals: " + waterfront + "\nNumber of non-waterfront rentals: " + nonWaterfront;
JOptionPane.showMessageDialog(null, output);
}//end process method
}//end Rental Class





