New Question:-
Write a program to perform conversion:-
1. Decimal To Binary and vice versa.
2. Decimal to Octal and vice versa.
3. Binary to Octal and vice versa.
4. Decimal to Hexadecimal and vice versa.
5. Octal to Hexadecimal and vice versa.
6. Binary to Hexadecimal and vice versa.
_
No Spamming please!
Answers
Answered by
17
Answer:
I have added all the programs in the txt file. Check it from there.
Note:
- The programs are solved using inbuilt functions.
- For 3rd, 5th, 6th and 7th question, it is better to convert the numbers to decimal equivalent and then convert the decimal equivalent to their respective number system.
Functions to be used:
- To convert from decimal to binary: Integer.toBinaryString(int). Resultant data type: String.
- To convert from any number system to decimal: Integer.parseInt(String_number,int_radix). If number is in binary format, radix=2 etc.
- To convert from decimal to octal: Integer.toOctalString(int). Resultant data type: String.
- To convert from decimal to hexadecimal: Integer.toHexString(int). Resultant data type: String.
Attachments:
Similar questions