Write a Java program that creates an array data of size 8, representing a binary number of 8 bits. The user must fillenter the clements of this array only by inputting 0 or 1. If the user enters any different number, the program must stop and display "Invalid data" message. If all entered digits are valid binary digits, the program must calculate and output the special decimal number represented by this binary number as shown in the below example: Ir the array data is 1 Result 1 X 20 + 0X 2 + 1 X 22 + 1X 2+ 0 X 21+ 0 X 2 + 0X 2 + 0 X 2 Result= 主 0. 4. 土 8. 0. 圭 0. 13 Then the result is calculated by ultiplying the value of the data array at each index with the result of 2 then adding all dhe answers. (shown in the ahove example) Sample run1: H«
Write a Java program that creates an array data of size 8, representing a binary number of 8 bits. The user must fillenter the clements of this array only by inputting 0 or 1. If the user enters any different number, the program must stop and display "Invalid data" message. If all entered digits are valid binary digits, the program must calculate and output the special decimal number represented by this binary number as shown in the below example: Ir the array data is 1 Result 1 X 20 + 0X 2 + 1 X 22 + 1X 2+ 0 X 21+ 0 X 2 + 0X 2 + 0 X 2 Result= 主 0. 4. 土 8. 0. 圭 0. 13 Then the result is calculated by ultiplying the value of the data array at each index with the result of 2 then adding all dhe answers. (shown in the ahove example) Sample run1: H«
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
![Write a Java program that creates an array data of size 8, representing a binary number of 8 bits.
The user must G/enter the elements of this array only by inputting 0 or 1, If the user enters any different
number, the program must stop and display "Invalid data" message.
If all entered digits are valid binary digits, the program must calculate and output the special decimal
number represented by this binary number as shown in the below example:
I the array data is
0 X 2 +
Result = 1 X 2 +
Result =
0 X 2 +
1 X 22 +
1X 2 +
0X 2 +
0X 2 +
0 X 2
0.
主
41
8.
0.
13
Then the result is calculated by niultiplying the value of the data aray at cach index with the result of 2
Ihen adding all dhe answers. (shown in the ahove example)
Sample run1:
Enter ihe](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fa1572cf6-4528-4b9b-846f-57eb6e26ec36%2F826248fa-6084-4ed9-b3fa-0e573a959650%2F38xaue_processed.jpeg&w=3840&q=75)
Transcribed Image Text:Write a Java program that creates an array data of size 8, representing a binary number of 8 bits.
The user must G/enter the elements of this array only by inputting 0 or 1, If the user enters any different
number, the program must stop and display "Invalid data" message.
If all entered digits are valid binary digits, the program must calculate and output the special decimal
number represented by this binary number as shown in the below example:
I the array data is
0 X 2 +
Result = 1 X 2 +
Result =
0 X 2 +
1 X 22 +
1X 2 +
0X 2 +
0X 2 +
0 X 2
0.
主
41
8.
0.
13
Then the result is calculated by niultiplying the value of the data aray at cach index with the result of 2
Ihen adding all dhe answers. (shown in the ahove example)
Sample run1:
Enter ihe
![Sample runl:
Enter the digits consisting of (0s or 1s): 2 5 4 1.3 2 5 7
Invalid data
Sample run2:
Enter the digits consisting of (0s or 1s): 11110 00 2
Invalid data
Sample run3:
Enter the digits consisting of (0s or 1s): 1 1 110 000
The number in decimal is 15
Sample run4:
Enter the digics consistirg of (0s or ls): 1 011:000 0
The number in decLmal is 13](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fa1572cf6-4528-4b9b-846f-57eb6e26ec36%2F826248fa-6084-4ed9-b3fa-0e573a959650%2Fn84q4tf_processed.jpeg&w=3840&q=75)
Transcribed Image Text:Sample runl:
Enter the digits consisting of (0s or 1s): 2 5 4 1.3 2 5 7
Invalid data
Sample run2:
Enter the digits consisting of (0s or 1s): 11110 00 2
Invalid data
Sample run3:
Enter the digits consisting of (0s or 1s): 1 1 110 000
The number in decimal is 15
Sample run4:
Enter the digics consistirg of (0s or ls): 1 011:000 0
The number in decLmal is 13
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps with 4 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Recommended textbooks for you
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY