using java Script

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Question
using java Script
Then the result is calculated by multiplying the value of the data array at each index with the result of 2d
then adding all the answers. (shown in the above example)
Sample runl:
Enter the digits consisting of (0s or ls); 2 5 4 1 3 257
Invalid data
Sample run2:
Enter the digits consistino of (0s er 1s): 1 1100 0 2
Invalid data
Sample run3:
Enter the digits consisting of (0s or Is): 111 1000O
The number in decmal is 15
Sample run4:
Enter the digits Consisting of (0s er 1s): 1 0 10000
The number in decimal is 13
Transcribed Image Text:Then the result is calculated by multiplying the value of the data array at each index with the result of 2d then adding all the answers. (shown in the above example) Sample runl: Enter the digits consisting of (0s or ls); 2 5 4 1 3 257 Invalid data Sample run2: Enter the digits consistino of (0s er 1s): 1 1100 0 2 Invalid data Sample run3: Enter the digits consisting of (0s or Is): 111 1000O The number in decmal is 15 Sample run4: Enter the digits Consisting of (0s er 1s): 1 0 10000 The number in decimal is 13
Write a Java program that cTeates an array data of size 8, representing a binary number of 8 bits.
The user must fill/enter 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 đigits 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:
If the array data is
1
Result = 1 X 2 +
OX 2 +
1 X 22 +
1 X 2 +
OX 2 +
0 X 2 +
0 X 2 +
0 X 27
Result =
4.
+
8.
|+ 0
13
Then the result is calculated by multiplying the value of the data array at cach index with the result of 2
then adding all the answers. (shown in the above example)
Sample runl:
Enter lhe dic r
57
Transcribed Image Text:Write a Java program that cTeates an array data of size 8, representing a binary number of 8 bits. The user must fill/enter 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 đigits 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: If the array data is 1 Result = 1 X 2 + OX 2 + 1 X 22 + 1 X 2 + OX 2 + 0 X 2 + 0 X 2 + 0 X 27 Result = 4. + 8. |+ 0 13 Then the result is calculated by multiplying the value of the data array at cach index with the result of 2 then adding all the answers. (shown in the above example) Sample runl: Enter lhe dic r 57
Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Introduction to computer system
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education