Java Write a program as follows: Prompt the user to enter a string containing a hexadecimal number. Use class Integer to parse the input to a base-10 integer variable and display it. Convert this base-10 variable to a string holding an equivalent number in binary. Print this binary equivalent. Use class Integer to convert the binary string back to base-10 and display it. SAMPLE OUTPUT Enter a string holding a hexadecimal integer less than 256 1a That hex number in base-10 is 26 As a binary number it's 11010 That binary number back to base-10 is 26
Java Write a program as follows: Prompt the user to enter a string containing a hexadecimal number. Use class Integer to parse the input to a base-10 integer variable and display it. Convert this base-10 variable to a string holding an equivalent number in binary. Print this binary equivalent. Use class Integer to convert the binary string back to base-10 and display it. SAMPLE OUTPUT Enter a string holding a hexadecimal integer less than 256 1a That hex number in base-10 is 26 As a binary number it's 11010 That binary number back to base-10 is 26
Chapter7: Characters, Strings, And The Stringbuilder
Section: Chapter Questions
Problem 6PE
Related questions
Question
Java
Write a
- Prompt the user to enter a string containing a hexadecimal number.
- Use class Integer to parse the input to a base-10 integer variable and display it.
- Convert this base-10 variable to a string holding an equivalent number in binary.
- Print this binary equivalent.
- Use class Integer to convert the binary string back to base-10 and display it.
SAMPLE OUTPUT
Enter a string holding a hexadecimal integer less than 256
1a
That hex number in base-10 is 26
As a binary number it's 11010
That binary number back to base-10 is 26
4. Write an executable program that has just a main method. In main:
- create an instance of StringBuilder that initially holds an empty string.
- append your first name to the string.
- append your surname to the string.
- display your name.
- insert your middle initial where it should be and spaces as needed. If you don't have a middle name, fake it.
- display your name with middle initial.
- delete your initial and the space(s).
- display your name in reverse order.
SAMPLE OUTPUT
John Public
John Q Public
cilbuP nhoJ
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
Step 1
Note: As per policy we are entitled to answer 1 question at a time.
Program Approach:
- Import necessary package
- Define main class
- Defining the main method
- Creating an object of the class
- Ask the user to enter a string holding a hexadecimal integer less than 256
- Reading values
- Declaring integer variable n
- Display the output
- Declaring method hexaToDecimal
- Defining string value
- Declaring method binToDec
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
![EBK JAVA PROGRAMMING](https://www.bartleby.com/isbn_cover_images/9781337671385/9781337671385_smallCoverImage.jpg)
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
![C++ Programming: From Problem Analysis to Program…](https://www.bartleby.com/isbn_cover_images/9781337102087/9781337102087_smallCoverImage.gif)
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
![EBK JAVA PROGRAMMING](https://www.bartleby.com/isbn_cover_images/9781337671385/9781337671385_smallCoverImage.jpg)
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
![C++ Programming: From Problem Analysis to Program…](https://www.bartleby.com/isbn_cover_images/9781337102087/9781337102087_smallCoverImage.gif)
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning