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 06:00
Which of the following is a way that advancements in technology improve humans' ability to measure air quality and protect human health? a. air quality data gathered by new instruments can be used to reduce exposure to pollutants. b. new technologies enable natural and human-made pollution sources to be located and monitored. c. air quality data gathered by new instruments can be used to predict trends in pollution over time. d. new technologies allow governments to make informed decisions about the regulation of pollution. (choose more than one)
Answers: 2
question
Computers and Technology, 22.06.2019 15:00
I'm taking a class on how to make a movie, and it offers some apps that would be in the process. the thing is, i don't have any of those ha. if you have any tips on some apps i could use, that would be awesome. i don't have an iphone, so don't suggest any apps like imovie. i know that this is a weird question, but it would be super for me. : )
Answers: 2
question
Computers and Technology, 22.06.2019 23:30
What does 21 pilots middle aged name as a band 15 years prior to them naming their band 21 pilots?
Answers: 1
question
Computers and Technology, 23.06.2019 21:40
Draw the resistor’s voltage and current phasors at t=15ms. draw the vectors with their tails at the origin. the orientation of your vectors will be graded. the exact length of your vectors will not be graded.
Answers: 2
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
Computers and Technology, 10.03.2020 02:59
Questions on the website: 13722360