The Question

Write a program called Q2.java that prompts for and then reads in a positive integer and a positive base and prints out the number in the specified base. HINT: You may find the static method Integer.toString(i, radix) useful.

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 the integer and the base in which int should be expressed ... 1023 2
1023 expressed in base 2 is 1111111111
%
%
% java Q2
Enter the integer and the base in which int should be expressed ... 60 4
60 expressed in base 4 is 330
%
%
% java Q2
Enter the integer and the base in which int should be expressed ... 12345 10
12345 expressed in base 10 is 12345
%

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 midtermF1 Q2.java