Back to Challenge Set 16

Code Challenge: Progress Bar

Difficulty  

divider

The Brief

What they asked for
Our download script just sits there. I want a text bar
that shows how far along it is. Give it a percent and it
draws the bar. Twenty characters wide looks about right.

Write your requirements list before you write any code. Input, calculate, output, and anything you had to decide for yourself.


Notes

  • The number of # characters is worked out from the percent. Nothing about the bar is typed in by hand: a loop draws it, one character at a time, with Console.Write.
  • Twenty characters is mentioned. Decide whether that is fixed or a second parameter, and say which.
  • 0% and 100% are the two that break. Test both before you submit.
  • Watch the order of * and /. Activity 1.6's integer division makes percent / 100 * 20 equal to 0 for every percent under 100.

Sample Output

Sample Output
[....................] 0%
[#####...............] 25%
[##########..........] 50%
[####################] 100%

Count the characters between the brackets on every line. There should be twenty each time.


Submit

Your requirements list and your program file, named cc-progress-bar.

Commence Challenge