Question: I am trying to design a Java Program which offers multiple things like Calculator and tetris game and many more. Both Calculator and Tetris game are written in Swing having GUI, but the main program is CLI. it presents options like press 1 for calculator , press 2 for tetris, etc. but as soon as I press 1 calculator launches in another window and my main program terminates. I want a method that my main program still gives options like press 1 for calculator , press 2 for tetris, etc. even when I close the GUI Calculator or Tetris Window. here's what I'm trying to do:

```
if (input == 1)
    {
        new Calc();
        mainScreen();
    }
else if (input == 2)
    {
        new Tetris();
        mainScreen();
    }
    .
    .
    .
    And So On

```

Answer: 
i would suggest adding an do{...}while(..); loop around your program so that it repeats the actions and you can add an exit command that quits the program

```
    String input;
    do{
        input = getInput();
        if (input.equals("1")) {
            new Calc();
            mainScreen();
        } else if (input.equals("2")) {
            new Tetris();
            mainScreen();
        }
    }while(!input.equals("exit"));

```
You can also pre-make the tetris game and calculator and do something like

```
        Calc calculator;
Tetris tetrisGame;
    if(input == 1) {

calculator = new Calc();
calculator.mainScreen();

    }
else if(input == 2) {

tetrisGame = new Tetris();
tetrisGame.mainScreen();

}

```

You could also make a constructor where you initialize these variables and then just use them.