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
173,812 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
173,812 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