Question: Introduction to Computing 2 Converter Program: Write a Java program (class) to receive a decimal number (base 10 number) between 0 and 255 and then
Introduction to Computing 2
Converter Program:
Write a Java program (class) to receive a decimal number (base 10 number) between 0 and 255 and then outputs its binary (base 2 number) equivalent.
Your program should also be able to receive a binary number between 0 and 255 (a series of 8 bits) and output its decimal equivalent (see table above). Notes on how to solve (pseudo code)
Your program should ask the user to input 'b' or 'B' if they want to convert from decimal to binary or 'd' or 'D' if you want to convert from binary to decimal
Convert from Decimal to Binary:
o If the user inputs 'b' or 'B' (You need to convert numbers from Decimal to Binary), then do the following:
Ask the user to enter a decimal number to convert to binary: You can use the Scanner class to input a decimal number between 0 and 255.
The number should be between 0 and 255. If it is not, it should print an informative error message (using System.out.println).
Now, your program should call a
method to perform conversion:
decimalToBinary: Write a method that converts the decimal number inputted by user to its binary equivalent
Make sure to print both numbers when done
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
