Hi all. Hope everyone is doing well. Hey, I'm trying to apply methods to a program I have previously written sequentially. I keep getting the following error because of my semicolon on line 31 that seems necessary to me so I don't understand why:
hotelDemo2Arnette.java:31: error: illegal start of expression
}
^
hotelDemo2Arnette.java:33: error: illegal start of expression
public static void getRooms()
^
Here is le code...
import javax.swing.JOptionPane; public class hotelDemo2Arnette { public static void main (String[] args) { getFloors(); getRooms(); getOccupied(); displayMethod(); } public static void getFloors() { String input; double occNum; double occNext; double occTot = 0; //Our variables.... double toNum; double floorNum; double floorTot = 0; Hotel worker = new Hotel(); //We make a new object.... input = JOptionPane.showInputDialog("How many floors does the hotel have?"); //Start getting our input. toNum = Double.parseDouble(input); for (int i = 1; i <= toNum; i++) } public static void getRooms() { input = JOptionPane.showInputDialog("How many rooms does floor " + i + " have?"); floorNum = Double.parseDouble(input); floorTot += floorNum; worker.setTotalRooms(floorTot); } public static void getOccupied() { input = JOptionPane.showInputDialog("How many occupied rooms does floor 1 have?"); occNum = Double.parseDouble(input); for (int i = 2; i <= toNum; i++) input = JOptionPane.showInputDialog("How many occupied rooms does floor " + i + " have?"); occNext = Double.parseDouble(input); occTot += occNext + occNum; worker.setTotalFull(occTot); } public static void displayMethod() { JOptionPane.showMessageDialog(null, "So that's " + worker.getTotalRooms() + " and " + worker.getTotalFull() + " are full."); JOptionPane.showMessageDialog(null, "That means you have " + worker.getOccupancy() + " rooms empty, " + "giving you an occupancy rate of " + worker.getVacancy() + "%" ); if (worker.getVacancy() < 80.0) { JOptionPane.showMessageDialog(null, "Contact Manager"); } System.exit(0); } }
--- Update ---
Here's this class btw,
public class hotelDemo1Arnette { private double totalRooms; private double totalFull; private double occupancy; private double vacancy; public hotelDemo1Arnette() { totalRooms = 0.0; totalFull = 0.0; occupancy = 0.0; vacancy = 0.0; } public void setTotalRooms(double rooms) { totalRooms = rooms; } public void setTotalFull(double full) { totalFull = full; } public double getTotalRooms() { return totalRooms; } public double getTotalFull() { return totalFull; } public double getOccupancy() { occupancy = totalRooms - totalFull; return occupancy; } public double getVacancy() { vacancy = (occupancy / totalRooms) * 100; return vacancy; }
--- Update ---
Also, I'm sure there are other compilation errors to come, but I can't get past this one at this point.
--- Update ---
I see it now. I had placed it right after a 'for' statement.