Home work agian.

I'm required to write a sales analysis program.

One of the function dose enter a new salesperson, it will prompt for personal detail. but if user keys in -1 at any point, it will cancel process and return to main menu options.

BUT according the programming standards of this, " GOTO statement, BREAK keyword and EXIT function are NOT allowed in any program. In C++ the use of Return to jump out of a function premeaturely is not Structured and therefore not allowed".

What can I do ?Thanks!!

Ok.. here is a very stupid idea..
Multithread, one thread that is suspendd for the main menue. One for input and one for checking for '-1'. If the third thread finds '-1' make it suspend the input and checking (itself) threads and activate the main meue thread. Although I am sure that a more elegant and easier solution is out there somewhere...
Instead of exit you can use abort().. for breaks use catch(?). And for goto use switch(?) although that would be hard.... I don't see how you need those though...
Ilya

Home work agian.

I'm required to write a sales analysis program.

One of the function dose enter a new salesperson, it will prompt for personal detail. but if user keys in -1 at any point, it will cancel process and return to main menu options.

BUT according the programming standards of this, " GOTO statement, BREAK keyword and EXIT function are NOT allowed in any program. In C++ the use of Return to jump out of a function premeaturely is not Structured and therefore not allowed".

What can I do ?Thanks!!

Ok.. here is a very stupid idea..
Multithread, one thread that is suspendd for the main menue. One for input and one for checking for '-1'. If the third thread finds '-1' make it suspend the input and checking (itself) threads and activate the main meue thread. Although I am sure that a more elegant and easier solution is out there somewhere...
Instead of exit you can use abort().. for breaks use catch(?). And for goto use switch(?) although that would be hard.... I don't see how you need those though...
Ilya

Thank you for your reply!
I'ver got an idea too, how about compare the input string with "-1".

while(!strcmp(ID,"-1"))
{
    cin << firstName;
    while(!strcmp(firstName,"-1"))
    {
         cin << lastName;
     }
}

How is that? Haven't tried no my code.

oh.. ok.. you have to make the entire string -1.. well then your idea is ok.. I though you were dealing with multiparagraph multiple strings that were constantly changed.... ya.. for this purpace your idea is the best..
Ilya

Thank you for your reply!
I'ver got an idea too, how about compare the input string with "-1".

while(!strcmp(ID,"-1"))
{
    cin << firstName;
    while(!strcmp(firstName,"-1"))
    {
         cin << lastName;
     }
}

How is that? Haven't tried no my code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.