title: Java: Integer division round up
body: <p>I'm trying to write a program that prompts the user to enter the total amount of floors in a hotel, the number of rooms in each floor, and the number of occupied rooms. In the end it should display the total # of rooms, the total # of rooms occupied, and the percentage of the rooms occupied. I am having problems with displaying the percentage of rooms occupied. I'm using all int numbers. </p>
  
  <p>This is the equation that I put:</p>
  
  <pre><code>roomsOccPercentage = (totalRoomsOccupied * 100) / totalRooms ;
  </code></pre>
  
  <p>When I submit the program into my professor's Java runner it displays: </p>
  
  <pre><code>65 % of the Rooms are occupied.
  </code></pre>
  
  <p>But the one my professor provided outputted the answer 66 % instead so the program won't accept my file. </p>
  
  <p>Does anyone know what I'm doing wrong? Is it a DecimalFormat error?</p>
  
  <p>Edit: Here is the whole code</p>
  
  <pre><code>import java.util.Scanner; 
  import java.text.DecimalFormat;
  
  public class hw7_1 {
      public static void main(String[]args) {
  
          Scanner keyboard = new Scanner(System.in);
          DecimalFormat formatter = new DecimalFormat("#0");
          int totalFloors;
          int totalRooms = 0;
          int numFloors;
          int numRooms;
          int roomsOccupied;
          int totalRoomsOccupied = 0;
          int roomsOccPercentage = 0;
  
          //prompting users to input # of floors, no inputs below 1 floor
          do {
              System.out.println("Please enter the number of floors in the hotel: ");
              numFloors = keyboard.nextInt();
  
              if (numFloors &lt; 1) {
                  System.out.println("You have entered an invalid number of floors. ");
              }
          }
          while (numFloors &lt; 1);
  
          //for loops on how many rooms on each hotel floors
          for ( int Floors = 1; Floors &lt;= numFloors; Floors++) {
              if (Floors == 13 ) {
                  continue;
              }
  
              do {
                  System.out.println("Please enter the number of rooms on floor #: " + Floors );
                  numRooms = keyboard.nextInt();
  
                  if (numRooms &lt; 10) {
                      System.out.println("You have entered an invalid number of rooms. ");
                  }
              } while (numRooms &lt; 10);
  
              System.out.println("Please enter the number of occupied rooms on floor #: " + Floors);
              roomsOccupied = keyboard.nextInt();
  
              totalRooms = totalRooms + numRooms;
              totalRoomsOccupied = totalRoomsOccupied + roomsOccupied;
              roomsOccPercentage = (totalRoomsOccupied * 100) / totalRooms ;
          }
          System.out.println("\nThe hotel has a total of " + totalRooms + " rooms.");
          System.out.println(totalRoomsOccupied + " of the rooms are occupied.");
          System.out.println(formatter.format(roomsOccPercentage) + "% of the rooms are occupied.");
      }
  }
  </code></pre>