Back to Challenge Set 10

Code Challenge: Step Tracker

Difficulty  

divider

The Brief

What they asked for
My watch gives me a step count every day and at the end of
the week I want the total, the average, and my best day. I
will type the seven numbers in.

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


Notes

  • Three of Activity 1.20's four patterns, in one loop and one pass of input. Work out which three before you start typing.
  • The average is where this one is won or lost. Your total is a whole number and seven is a whole number, and C# divides those the way Activity 1.6 said it would. The answer you get will have a decimal point on it and will still be wrong.
  • Check the average by hand before you trust it. Seven numbers adding to 62,600 do not average to a round figure, so an answer ending in .0 is a red flag rather than a coincidence.
  • One decimal place on the average. The customer asked for a number they can read.
  • Step counts are never negative, so the starting value for the best day is safe at 0 here. Say in your requirements list that you relied on that — it is a decision, not a given.

Sample Output

Sample Output
Day 1 steps: 8200 [Enter]
Day 2 steps: 10400 [Enter]
Day 3 steps: 6100 [Enter]
Day 4 steps: 12750 [Enter]
Day 5 steps: 9300 [Enter]
Day 6 steps: 4800 [Enter]
Day 7 steps: 11050 [Enter]
Total: 62600
Average: 8942.9
Best day: 12750

Use these seven numbers to test, and check all three answers. The total is 62,600, the best day is 12,750, and the average is 8,942.9 — not 8,942.0.


Submit

Your requirements list and your program file, named cc-step-tracker.

Commence Challenge