Functionality
Write Java program to convert numbers in one number system to others.
Requirement
- Write Java program to implement functions to:
- convert binary number to decimal and hexadecimal number
- convert decimal number to binary and hexadecimal number
- convert hexadecimal number to binary and decimal number
(You
cannot
use any Java build-in functions/methods to perform conversion)
- The program will repeatedly display the following menu:
- Binary to hexadecimal and decimal
- Hexadecimal to binary and decimal
- Decimal to binary and hexadecimal
- Exit
User enters a number (1, or 2, or 3) to select one item from the meu to perform conversion: once a menu item is selected, user is prompt to enter a number (in string). If this number is valid, the program will convert it to other 2 number systems. Display these 3 values.
For example, if menu item 1 is selected, user will be prompt to enter a binary number (in
string). This number will be converted to decimal number and hexadecimal number. The following message is displayed:
Binary number: [binary-number]
Decimal number: [decimal-number]
Hexadecimal number: [hexadecimal-number]
After that, the menu will be displayed again, so user can select another item.
If menu item 4 is entered, the program will be terminated.