Question: Write a program that prompts the user to enter an integer literal from 0 to 15 (inclusive) as either a decimal, hexadecimal, or binary literal.
Write a program that prompts the user to enter an integer literal from 0 to 15 (inclusive) as either a decimal, hexadecimal, or binary literal. When entering values as hexadecimal or binary literals the user should follow the notation specified in the first note on page 49 of the textbook. For example, the user might enter the value 15 as the hexadecimal literal 0xF, or as the binary literal 0b1111, or the decimal literal 15. The program should output the value entered by the user in all three bases: i.e., decimal, hexadecimal, and binary. For example, if the user entered 0b1100, the program should output 12, 0xC, and 0b1100 as the decimal, hexadecimal, and binary representations. The users input should be read as a string. Do NOT use loops, the parseInt method, or any pre-written method that converts from one base to another.[java]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
