Write a Java or C++ program that will convert an array of char supplied in hex, octal, binary or decimal and print out a the number as a string or array of char in all four formats stated above.
Specifications:
The program cannot perform I/O on integer data types. Example, if x is an integer, the statements System.out.println(x) or printf("%d",x) (or %o, %x etc) or cout << x are not permitted. I/O can only be performed on characters.
The program can only input and output strings or individual characters.
The class is to have public function members (methods) called
toNumber which returns the integer represented by the data array.
toCharacter which takes as parameters the integer the base of the number. That charater string is to be placed in the array method (member) of the object.
printNumber which prints one character at a time, the contents of the data array.
A constructor that initalizes the object.
A boolean method (member) called isValid validates input in so far as the characters within the data portion are valid for that number type.
Program is not to deal with numbers greater than 32767 or negitive numbers.
The only package / library functions you are allowed to use are I/O of single characters, You may use library functions such as clrscr for output enhancement.
Code must be modularized.
The toNumber method is to convert the input string into an integer using Horners' Method.
The program must contain functions and/or procedures to validate input.