You nearly have it, have a read of this :
Just need to add the bool controlled while loop.
Also the code would be tidier, if each case called a function, rather than having a big long winded switch. The code which shows the menu should be in it's own function as well.
Declare the functions before main(), then place the definitions of them after main()
And avoid the
using namespace std;
- it brings the whole of the std namespace into the global one, which can cause naming conflicts - which is what we are trying avoid. Do you realise there are a number commonly used words in
to name just a few. So if you had a variable or function called distance, the compiler would throw out all kinds of messages, because
means a very different thing.
So you can put
thing (a lot of people do this), or you can put these at the top of your file :
Then use them without qualification after that.
Ideally, one should always put their code in a
of it's own. You can read about in the reference section top left of this page.
Hope all goes well.