Homework 00
Binary Changer
Due 09/13/2024 by 11:55PM
Objective:
Write a program that accepts two four-digit binary numbers, converts them to decimal values, adds them together, and prints both the decimal values and the result of the addition.
Requirements:
Hint:
A simple way to convert a binary value to a decimal value.
Binary Digit |
b0 |
b1 |
b2 |
b3 |
Base 2 Value |
23 |
22 |
21 |
20 |
Result |
b0 x 23 |
b1 x 22 |
b2 x 21 |
b3 x 20 |
Example:
Binary Digit |
0 |
1 |
1 |
1 |
Base 2 Value |
23 |
22 |
21 |
20 |
Result |
0 |
4 |
2 |
1 |
Example:
Binary Value = 0 + 4 + 2 + 1 = 7 |
Example Dialog:
*The following Example Dialog demonstrates the interactions
between a user and ONE possible implementation of the required software’s
front-end / user interface. The software’s front-end / user interface may
be implemented in MANY different ways and will receive full credit as
long as it meets the most minimal of the above requirements. While you may use
the example dialog as a guide, it is strongly encouraged to create the
front-end / user interface in your own way. *
Key |
|
Unhighlighted Text |
Program’s Output |
Highlighted Text |
User’s Input |
Enter a 4-bit binary number
0111
Enter another 4-bit binary number
0010
The first number is 7
The second number is 2
Added together is 9
Finally:
Upload the solution’s source file (.JAVA extension) to the CSCE Dropbox