Perhaps there is a way to call a new terminal to open with the remaining code while closing the old one? I have no idea how to do that... but that would guarantee a clear terminal/DOS window etc...
That is, unless
System.out.print ("\033c"); does clear all the contents of the terminal window so that even if you scrolled up you could not find the text cleared.
As far as the suggestion about the GUI, he/she is quite correct. A GUI just draws a new layer over the text and it appears to disappear. However making a GUI window of the right size, right color, centered in the computer screen, with font of the right size, right color centered in the GUI that accepts inputs and displays outputs is like five times the code you originally posted. Thus, making the GUI might be something of a pain.