The Question

Write a program called Q2.java that prompts for and reads in a line of text and then print out the line backwards.

The output should conform to that in the sample runs of a correct program shown below. Note that, in these sample runs, the % sign is not part of the output. User input is shown on the same line as the prompt.

Sample Runs

% java Q2
Enter a line of text ... This is an example
The line written backwards is : elpmaxe na si sihT
%
%
% java Q2
Enter a line of text ... able was I ere I saw elba
The line written backwards is : able was I ere I saw elba
%
%
% java Q2
Enter a line of text ... the end
The line written backwards is : dne eht
%

Useful APIs

Here (again) are the common APIs that you may access:

Java 1.5 API
Type API

Submitting Your Work

Here is the command to submit your work (further details regarding the submit command can also be obtained by typing man submit
Once again, you are encouraged to submit regularly. Newer submissions overwrite older ones.

submit 1020 midtermT1 Q2.java