Progress bar code I found

public String generateProgressBar() {
  int total = getSizeX() * getSizeY() * getSizeZ(); // Area
  double percentage = this.visitedBlocks / total;
  StringBuilder progBar = new StringBuilder();
  progBar.append(Math.round(percentage * 100)).append("% ["); // 0.1 becomes 10
  int bars = (int) percentage * 10; // 0.1 becomes 1
  for (int bar = 1; bar <= 10; bar++) {
    if (bars >= bar) {
      progBar.append('#');
    } else {
      progBar.append('_');
    }
  }
  progBar.append(']');
  return progBar.toString();
}