title: How to calculate how many tiles you need for a tile-floor in Java
body: <p>I just recently started programming and ran into this problem.</p>
  
  <p>How do I calculate how many tiles I need for a tile-floor?
  The tile is a square with a width of 20, the floor length and width are inputted by the user.</p>
  
  <p>I can calculate how many full tiles I need by using % but once I get to the tile pieces on the side, I'm stuck. Cutting in smaller strips is allowed, you just can't make a mosaic.</p>
  
  <p>I've tried storing the sizes in a list and adding them up to as close as possible to 20. But then I run into things like using a tile for 2 pieces of 8 and using 2 tiles for 2 pieces of 12, while 2 tiles would be enough.</p>
  
  <p>I can't seem to find a way to code that logic in.</p>
  
  <pre><code>final int tile = 20;
      double length = Input.readDouble();
      double width = Input.readDouble();
  
      int completeColumTiles = (int)width/tile;
      int completeRowTiles = (int)length/tile;
      int tilesWithoutRest = completeRowTiles * completeColumTiles;
  
      double restLength = length%tile;
      double restWidth = width%tile;
  
      int tilesRest = calculateRest(completeColumTiles, completeRowTiles, restLength, restWidth);
      int tilesWithRest = tilesWithoutRest + tilesRest;
  
      System.out.println("You need " + tilesWithRest + " tiles.");         
  </code></pre>
  
  <p>So basically i need help with the calculateRest </p>