Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace HomeWorks
- {
- class Program
- {
- static void Main(string[] args)
- {
- int barMaxPercent = 100;
- int barPercent;
- string userInput;
- char barSymbol;
- int barLength = 10;
- bool isOpen = true;
- while (isOpen)
- {
- Console.Write("Введите процент заполненности bar: ");
- userInput = Console.ReadLine();
- if (userInput == "exit")
- {
- isOpen = false;
- }
- barPercent = Convert.ToInt32(userInput);
- if (barPercent > barMaxPercent)
- {
- barPercent = barMaxPercent;
- }
- else if (barPercent < 0)
- {
- barPercent = 0;
- }
- Console.Write("Введите символ, которым будет заполнен bar: ");
- barSymbol = Convert.ToChar(Console.ReadLine());
- DrawBar(barPercent, barSymbol, barLength, barMaxPercent);
- }
- }
- static void DrawBar(int barPercent, char barSymbol, int barLength, int barMaxPercent)
- {
- Console.Clear();
- Console.Write("[");
- int barOnePoint = barMaxPercent / barLength;
- if (barPercent > 0 && barPercent < barOnePoint)
- {
- Console.Write(barSymbol);
- }
- for (int i = 1; i < barLength; i++)
- {
- if (i <= barPercent / barOnePoint)
- {
- Console.Write(barSymbol);
- }
- else
- {
- Console.Write("_");
- }
- }
- Console.WriteLine($"] {barPercent}%");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement