Advertisement
Dr_Max_Experience

Task 20

Nov 15th, 2021 (edited)
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.44 KB | None | 0 0
  1. using System;
  2.  
  3. namespace HomeWorks
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int barMaxPercent = 100;
  10.             int barPercent;
  11.             string userInput = "";
  12.             char barSimbol;
  13.             int percentageDivider = barMaxPercent / 10;
  14.  
  15.             while (userInput != "exit")
  16.             {
  17.                 Console.Write("Введите процент заполненности bar: ");
  18.                 barPercent = Convert.ToInt32(Console.ReadLine());
  19.                 Console.Write("Введите символ, которым будет заполнен bar: ");
  20.                 barSimbol = Convert.ToChar(Console.ReadLine());
  21.  
  22.                 DrawBar(barPercent,barSimbol, percentageDivider);
  23.             }
  24.         }
  25.  
  26.         static void DrawBar(int barPercent, char barSimbol, int percentageDivider)
  27.         {
  28.             Console.Clear();
  29.  
  30.             int barFullness = barPercent / percentageDivider;
  31.             int barUnfilledPart = percentageDivider;
  32.             Console.Write("[");
  33.  
  34.             do
  35.             {
  36.                 Console.Write(barSimbol);
  37.                 barFullness--;
  38.                 barUnfilledPart--;
  39.             }
  40.             while (barFullness > 0);
  41.  
  42.             for (int i = barUnfilledPart; i > 0; i--)
  43.             {
  44.                 Console.Write("_");
  45.             }
  46.             Console.WriteLine($"] {barPercent}%");
  47.         }
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement