I can't figure out why 'display' in the main method wont show in my output. Any help will be appreciated.
Code:
import javax.swing.JOptionPane; public class lab006 { public static void main (String [ ] args) { int numRoom; numRoom = number(); String display=""; int numberOfRooms = 0; int length=0; int width=0; String name=""; int area=0; int totalArea=0; for(int i = 0; i < numRoom; i++) { name = JOptionPane.showInputDialog("Enter name of room"); do { width =Integer.parseInt(JOptionPane.showInputDialog("The width of " + name + " --in feet")); } while(width <= 0 || width >= 30); do { length =Integer.parseInt(JOptionPane.showInputDialog("The length of " + name + " --in feet")); } while(length <= 0 || length >= 30); area=length*width; totalArea+=area; display+= name + area + "\n\n\n"; } finalOutput(display, totalArea); } public static int number () { int numberOfRooms=0; do { numberOfRooms = Integer.parseInt(JOptionPane.showInputDialog("How many rooms in the house?"));//display message box to get the number of rooms } while (numberOfRooms >= 10 || numberOfRooms <= 0); return numberOfRooms; } public static void finalOutput(String output, int totalArea) { output="Room | Area\n"; output += "Total Square Footage: " + totalArea + " square feet"; JOptionPane.showMessageDialog(null, output); } }
Comment