computer science /use java language

posted by .

write the program that inputs a string representing a binary number(0s and 1s). First, your program should veerify that it is indeed a binary number, that is, the number contains only 0s and 1s . if that is not the case, your program should print a message that number is not a valid binary number.then your program should count how many 1s are in that string and output the count. if the string does not represent a valid binary number, the program should keep prompting the user for a new string until a string representing a valid binary number is input by the user.

Respond to this Question

First Name
School Subject
Your Answer

Similar Questions

  1. Computers (Java)

    Hello -- Looking for help with an extra credit assignment to give my grade a needed boost. The program is to display a star pattern with java loops. From prof: Write a program using loops to display the star pattern that follows the …
  2. math

    the binary system is used for computer programming. a binary number consists of a string of digits that are either 0s or 1s a. if a string of binary code is 5 digits long, how many binary numbers are possible if the first digit is …
  3. programming 2

    Write a program that inputs a word representing a binary number (0s and 1s). First, your program should verify that it is indeed a binary number, that is, the number contains only 0s and 1s. if that is not the case, your program should …
  4. Programming in c++

    Write a program in c++ that inputs a number [1-12] from the user and displays the month. it also asks the user whether he wants to input another number or not, if the user inputs 1 then it again inputs number, if user inputs 0 then …
  5. Python programming Language

    Assume S is a string of lower case characters. Write a program that counts up the number of vowels contained in the string S. Valid vowels are 'a', 'e', 'I', 'o', and 'u'. For example, if S='azcbobobegghakl' your program should print: …
  6. java programming

    Your boss at Ruritania Weather Center (RWC) has asked you to write a small program for center. The specification are as follows: a. the program asks a user to enter a number between 1 and 12 inclusive representing the months January …
  7. java. please help .

    Write a program that reads a five digit integer number from the keyboard, and then constructs the largest possible integer number with the digits of the entered number. Your program should have only one class , which implements the …
  8. java

    Write a program that reads a five digit integer number from the keyboard, and then constructs the largest possible integer number with the digits of the entered number. Your program should have only one class , which implements the …
  9. programming ( qbasic)

    i was given this program by my teacher. it converts decimal number to binary number.. Why is that FIX kept in front of (n/2) ...6th line of the program. why is that FIX written and why?
  10. computer programing

    okay I need a little help here on next program this what it say for first one which I have done. Create a counting program that counts backward from 100 to 1 in increments of 10. #include < stdio.h > int main () { Int i; while …

More Similar Questions