Independent Reading

 

Number base conversion. 

 

Write a program which will read an unknown number of lines from a file called NumberBase.txt. Each line has the following: (1) a number in the range 2 through 16 representing a number base. This number will be followed by a single blank and then (2) a string representing a number value in the base of the first number. For each line, determine the value in base 10 of the string. Print the original number, the base, and the base 10 value in that order, all on a single line. The last line of the file has the number 0. Name your program NumberBaseXxx.java where the “Xxx” is your user name.

 

Example: If the input file is:

2 11111111              (this means the number 11111111 is in base 2)

5 123                   (this means the number 123 is in base 5)

0

 

The output should be:

2 11111111 255

5 123 38