Waiting for answer This question has not been answered yet. You can hire a professional tutor to get the answer.
Write a program that inputs a string that represents a binary number. The string can contain only 0s and 1s and no other characters, not even spaces....
Write a program that inputs a string that represents a binary number. The string can contain only 0s and 1s and no other characters, not even spaces. Validate that the entered number meets these requirements. If it does not, display an error message. If it is a valid binary number, determine the number of 1s that it contains. If it has exactly two 1s, display "Accepted". Otherwise, display "Rejected". All input and output should be from the console.Examples of invalid binary numbers: abc1010201110101
FF0000 1111 (note: contains a space)
Examples of valid, rejected binary numbers: 00000000111101110000001Examples of valid, accepted binary numbers: 10000011100Your program will only test one input for each run of the program. Testing each of the test cases requires a separate run of your program for each one.
The following 3 test runs illustrate the format of the program's console input and output:
Enter a binary number > abc Invalid binary number.
Enter a binary number > 01110000001 Rejected
Enter a binary number > 1000001 Accepted