Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Basic_Task17
- {
- class Program
- {
- static void Main(string[] args)
- {
- DrawBar(45);
- DrawBar(20, 2);
- DrawBar(100, 4);
- }
- public static void DrawBar(int percent, int position = 0)
- {
- string bar = "[";
- if (percent > 100)
- {
- percent = 100;
- } else if (percent < 0)
- {
- percent = 0;
- }
- for (int i = 1; i <= 10; i++)
- {
- if (percent / 10 >= i)
- {
- bar += "#";
- } else
- {
- bar += "_";
- }
- }
- bar += "]";
- Console.SetCursorPosition(0, position);
- Console.WriteLine(bar);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement