Question: Java Problem Description/Purpose: Write a program to accept a String of 5 characters. The user should only input a STRING of characters where each character

Java Problem Description/Purpose:

Write a program to accept a String of 5 characters. The user should only input a STRING of characters where each character is either a '0' or '1'. Each character in this String represents a bit such that the input is a 5 bit Binary Number. Write a program that reads a five-bit binary number from the keyboard as a String and then converts it into decimal.

Example: User input is 10100, the output should be the decimal number 20.

Hint: Break the string into substrings, then to char. Use the ASCII table to find the Int

value of the char. You will need to use basic math to reach the decimal equivalent of the Binary number.

Standards:

Your data input MUST be a String

Your input MUST BE 5 characters, no spaces and each character a 0 or a 1

You must use the ASCII table to find the int equivalent of a char

You must use the basic MATH and ALL THINGS covered in class and through Zybooks to solve the problem.

Objectives:

Practice what you have learned:

Character as Binary

ASCII table

Binary to Decimal Calculations

Primitive Data Types

String Data Type

String Manipulation Methods

Programming basics

Comments

Requirements/Task(s):

The user should input a STRING. The string can be any binary sequence of 5 bits

Feel free to create AS MANY variables as you need.

Use the appropriate programming techniques to solve the problem.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!