Hello there!

Right, Im designing a simple program for college. Its just a basic wage input program and it works fine. On the final screen I want the user to have the option of going back to the start of the program. 'Do you wish to start again?(y/n)' so if they type 'y' then they will be brought back to the first screen. Can this be done and if so how?

Any help much appreciated!

Shane

Recommended Answers

All 4 Replies

program keepGoing;
uses
  SysUtils;
var
  Response: string;
begin
  Response := 'Y';
  repeat
    // Do your stuff here.
    write('Do you want to continue? ');
    readln(Response);
  until UpperCase(Response) = 'N';
end.

This works too:

int main()
{
begin:

//main code over here

restartchoice:

     char choice;
     cout << "Do you wish to start again?(y/n): ";
     cin >> choice;
	
     switch(choice)
     {
     case 'Y' :
     case 'y' :
          goto begin;
     break;

     case 'N' :
     case 'n' :
          goto end;
     break;

     default:
          cout << "You must either enter Y to start again, or N to end the program." << endl << endl;
     system("pause");
     goto restartchoice;
     }

end:
return 0;
}

Good luck :)

You do realize that this thread is over three years old?

...And that using goto for this instead of a loop is Wrong...

...And that this is the Pascal and Delphi forum...

(But at least you didn't call main(); ;) )

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.