Click here to Skip to main content
15,899,020 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello guys. I need some of your time to help me...

What I've been told to do :
1. Create a menu that contains the following options: Get a persons details (p) Get the Salary (s) Calculate and display (d) Exit (x)<br />
2. Display the menu and wait for the users response.<br />
3. Process the options entered until the user enters 'x' to quit.<br />
Using a switch statement organise the code to suit the options.


I need some help on looping and repetition because I'm expected to put appropriate effort into allowing the user to re-enter data that has been detected as invalid
I only can use for Loop, while Loop do while Loop and nested loops.


What I've done so far...

nothing.
Posted
Updated 21-Aug-12 23:23pm
v3
Comments
[no name] 20-Aug-12 7:44am    
You are expected to show appropriate effort here too. This is a code dump without a question being asked. No one here will do your homework for you.
[no name] 20-Aug-12 8:12am    
Help with what? You did not bother asking any kind of a question. You just dumped your code here and expect us to do what with it? If you are constrained to using for loops and do-while then crack open your textbook and start reading.

There is some very useful information in .NET Book Zero[^] by Charles Petzold, which explains how to use such features. He also goes a long way to explain the use of classes and objects.
 
Share this answer
 
Comments
Richard MacCutchan 20-Aug-12 12:54pm    
Unfortunately, that is the help you need to solve the issue you are asking about. As it stands your program is not very well structured so a complete answer would require changes to much of the code.
Your loop has various exit conditions, and various looping conditions. Best bet will be to create an infinite while loop and exit it with break statements as appropriate. for eg:

C#
while(true)
{
    while(input is invalid)
    {
       //ask for and validate input
    }

    //Do work with the validated input here
 
    if(user wants to exit)
    {
       break;
    }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900