Advertisement
JeffGrigg

Untitled

Jan 23rd, 2023
2,871
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 1.06 KB | None | 0 0
  1.     private static final int TOTAL_NUMBER_OF_DOTS = 10;
  2.  
  3.     private static String getPercentageRounds(final double percentage) {
  4.         final var pot = max(min((int) ceil(percentage * TOTAL_NUMBER_OF_DOTS), TOTAL_NUMBER_OF_DOTS), 0);
  5.         switch (pot) {
  6.             case 0: return "⚪⚪⚪⚪⚪⚪⚪⚪⚪⚪";
  7.             case 1: return "🔵⚪⚪⚪⚪⚪⚪⚪⚪⚪";
  8.             case 2: return "🔵🔵⚪⚪⚪⚪⚪⚪⚪⚪";
  9.             case 3: return "🔵🔵🔵⚪⚪⚪⚪⚪⚪⚪";
  10.             case 4: return "🔵🔵🔵🔵⚪⚪⚪⚪⚪⚪";
  11.             case 5: return "🔵🔵🔵🔵🔵⚪⚪⚪⚪⚪";
  12.             case 6: return "🔵🔵🔵🔵🔵🔵⚪⚪⚪⚪";
  13.             case 7: return "🔵🔵🔵🔵🔵🔵🔵⚪⚪⚪";
  14.             case 8: return "🔵🔵🔵🔵🔵🔵🔵🔵⚪⚪";
  15.             case 9: return "🔵🔵🔵🔵🔵🔵🔵🔵🔵⚪";
  16.             case 10: return "🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵";
  17.             default: return "⚪⚪⚪⚪⚪⚪⚪⚪⚪⚪";
  18.         }
  19.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement