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

here is a snapshot

https://w.trhou.se/5b9as532r0 this is my work I need help because when I typed done it crashed also i don't know hoe to divide the numbers entered by the user

1 Answer

Steven Parker
Steven Parker
231,275 Points

The program says to type "done", but it's really looking for "quit".

So "done" just causes an invalid number conversion (and then crashes).

Some other hints:

  • in addition to the total, you will probably want to keep a count of entered numbers in the loop
  • when the loop ends, you can then divide the total by the count to get the average
  • the symbol for a divide operation is a slash ("/')
  • you can then use WriteLine to show that average, much like you already show the total
ali raafat
ali raafat
444 Points

and how can keep track of what the user did and also how can i divide the total of the user i know that / is sign for didvide but i dont kn ow what should i do, and should i change done to quit.

Steven Parker
Steven Parker
231,275 Points

You can keep a count in the loop where you add the numbers for the total (be sure to declare an initialize count before the loop):

                total += numbers;  // you already do this
                count += 1;        // you could do this too

Then when the loop finishes, you could do something like this:

        Console.WriteLine(" Your average is " + total / count);  // output the average
        Console.WriteLine("Goodbye" );                          // you already do this

And to end the sequence, you could either tell the user to type "quit", or inside the program check for "done" instead of "quit". As long as they match, either way is fine.