0

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

4
Contributors
4
Replies
6
Views
12 Years
Discussion Span
Last Post by Duoas
0
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.
0

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;
}
0

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(); ;) )

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.