code: public static String percentageBar(double percentage) {
          final char  dot   = '.';
          final char  mark  = '#';
          final int   slots = 40;
  
          StringBuilder bar = new StringBuilder(replicate(String.valueOf(dot), slots));
          int numSlots = (int) (slots * percentage / 100.0);
          for (int k = 0; k < numSlots; ++k) bar.setCharAt(k, mark);
  
          return String.format("[%s] %3.0f%%", bar, percentage);
      }
docs: Creates a percentage ASCII bar.
  @param percentage    value in [0, 100]
  @return "[###......] nn%"