title: Given a room number, find the floor on which room it lies java
body: <p>I came across a question where I had to find the floor by using given room no, according to the following distribution:</p>
  
  <pre><code>floor    rooms
  1        1-5
  2        6-15
  3        16-20
  4        21-30
  5        31-35
  6        36-45
  </code></pre>
  
  <p>. Suppose if I am giving room number as "37" program should say "floor number is 6". Though I have given below solution for it but I itself felt its not a good solution. I believe It may fail if the number of floor is increasing.</p>
  
  <pre><code>    int queryRoom = 37;
      int totalFloor = 6;
  
      int currentRm = 0;
      int floorInQuestion = 1; // staring floor
  
      while (floorInQuestion != totalFloor) {
          if (floorInQuestion % 2 != 0) {
              currentRm = currentRm + 5;
          } else {
              currentRm = currentRm + 10;
          }
          if (queryRoom &lt;= currentRm)
              break;
          floorInQuestion++;
      }
  
      System.out.println(floorInQuestion);
  </code></pre>