subject

The parity bit of a sequence of bits is O if the number of 1's in the sequence is even and 1 otherwise.
Example:
if the sequence of bits is 1 1 0 1, the parity bit should be 1 (total number of 1-bits is 3 which
is odd)
if the sequence of bits is 1010, the parity bit should be 0 (total number of 1-bits is 2 which
is even)
Write a Java program that asks the user to enter the number of bits he has. The program then
reads the bits as separate integers. In the end, the program prints the parity bit on the screen. If
the use enters a bit value that is neither 0 nor 1, the entry should be discarded and a message
displayed as shown in the sample run.
Sample run 1:
How many bits do you have? 6
Enter 6 bits: 1 1 0 0 1 0
The parity bit is 1
Sample run 2:
I
How many bits do you have? 8
Enter 8 bits: 1 1 1 0 0 0 0 1
The parity bit is O
Sample run 3:
How many bits do you have? 5
Enter 5 bits: 1 1 3 0 1
Incorrect bit value 3 is discarded.
The parity bit is 1​

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 16:30
The most common battery cable terminal is a that provides a large surface contact area with the ability to tighten the terminal onto the battery post using a nut and bolt.
Answers: 2
question
Computers and Technology, 22.06.2019 18:10
How can i delete permalinks from a word press site?
Answers: 1
question
Computers and Technology, 23.06.2019 12:00
If you embed a word table into powerpoint, what happens when you make edits to the embedded data? a. edits made to embedded data change the data in the source file; however, edits made to the source file will not be reflected in the embedded data. b. edits made to embedded data will change the data in the source file, and edits made to the source file will be reflected in the embedded data. c. edits made to embedded data don't change the data in the source file, nor will edits made to the source file be reflected in the embedded data. d. edits made to embedded data don't change the data in the source file; however, edits made to the source file will be reflected in the embedded data.
Answers: 1
question
Computers and Technology, 23.06.2019 17:00
1. which of the following is not an example of an objective question? a. multiple choice. b. essay. c. true/false. d. matching 2. why is it important to recognize the key word in the essay question? a. it will provide the answer to the essay. b. it will show you a friend's answer. c. it will provide you time to look for the answer. d. it will guide you on which kind of answer is required.
Answers: 1
You know the right answer?
The parity bit of a sequence of bits is O if the number of 1's in the sequence is even and 1 otherw...
Questions
question
History, 20.09.2020 15:01
question
Mathematics, 20.09.2020 15:01
question
Mathematics, 20.09.2020 15:01
question
Mathematics, 20.09.2020 15:01
question
Chemistry, 20.09.2020 15:01