Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

C# C# Basics (Retired) Perfect Wrap Up

ali raafat
ali raafat
444 Points

i how can i add this

i need to add the numbers entered by the user then get the averager when he types done so i did a var entry = Console.ReadLine(); but then what should i do

how many numbers can/should the user enter into the console?

1 Answer

Steven Parker
Steven Parker
231,248 Points

Here's a few hints:

  • you will need a loop
  • ReadLine will give you a string, you'll need to convert it into a number (remember the "Yay!" challenge?)
  • then, you will want to accumulate a running total and also keep a count of the inputs
  • after you get a "done", you will exit the loop
  • then you can divide the total by the count to get the average
  • finally, you will output the average and the program is over
ali raafat
ali raafat
444 Points

i converted it . I will make a loop and use if/else but what does accumulate a running total and also keep a count of the inputs mean

Steven Parker
Steven Parker
231,248 Points

I was thinking that inside your loop, you would have something like this (your variable names may differ):

    total += thisValue;  // accumulate a running total
    count += 1;          // keep the count of inputs