Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void Main(string[] args)
- {
- int positionY = 5;
- int positionX = 0;
- int lengthBar = 30;
- int maxPercent = 100;
- int minPrecent = 0;
- Console.WriteLine($"Максимальное значение %: {maxPercent}\nМинимальное значение %: {minPrecent}");
- Console.Write("Введите процент: ");
- float percent = Convert.ToSingle(Console.ReadLine());
- DrawingBar(lengthBar, percent, positionX, positionY, ref minPrecent, ref maxPercent);
- }
- private static void DrawingBar(int lengthBar, float percent, int positionX, int positionY, ref int minPrecent, ref int maxPercent)
- {
- if (percent >= minPrecent && percent <= maxPercent)
- {
- int convertValue = Convert.ToInt32(lengthBar * (percent / maxPercent));
- char inputFillingChar = '#';
- char fillingEmptySpacechar = '_';
- string bar = "[";
- Console.SetCursorPosition(positionX, positionY);
- AddChars(convertValue, inputFillingChar, ref bar);
- AddChars(lengthBar - convertValue, fillingEmptySpacechar, ref bar);
- Console.Write(bar + "]\n\n");
- }
- else
- Console.WriteLine("Введено некорректное значение");
- }
- private static void AddChars(int parameterValues, char inputChar, ref string bar)
- {
- for (int i = 0; i < parameterValues; i++)
- {
- bar += inputChar;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement