Yes. It is a little awkward, however, because the user prompts as well as the computed answer will be sent to the output text file.
Here is an example of redirecting the output of this file. The user does not see any prompts because they have been sent to the output file:
C:\temp>java Discount > discount.out 100 20 C:\users\default\JavaLessons>type discount.out Enter list price in cents: Enter discount in percent: Discount Price: 80 C:\temp>
This is somewhat awkward: the user sees half the dialog, and the other half goes to the file. It would be better if both the monitor and the file got the complete dialog.
Would it be useful if their were a way to send some output to the monitor, even when redirection is being used?