write a java program to check whether given number is binary or not
Java
import java.util.Scanner;
public class CheckNumberisBinary
{
public static void main(String args[])
{
int r=0,c=0,num,b;
Scanner sl=new Scanner(System.in);
System.out.println("Enter a number");
num=sl.nextInt();
b= num;
while(num>0)
{
if((num %10==0)|| (num%10==1))
c++;
r++;
num=num/10;
}
if(c==r)
System.out.println(b+" is a Binary Number.");
else
System.out.println(b+" is not a Binary Number");
}
}
Also in Java:
- Title
- how to convert string to double in android studio
- Category
- Java
- Title
- create instance object java
- Category
- Java
- Title
- java indexof not found
- Category
- Java
- Title
- java bucket sort
- Category
- Java
- Title
- get first 5 characters of string java
- Category
- Java
- Title
- how to change the color of a menubar in java
- Category
- Java
- Title
- deserialize date java
- Category
- Java
- Title
- android studio remove notification bar
- Category
- Java
- Title
- insertion sort doubly linked list java
- Category
- Java
- Title
- java function that returns the index of the largest value in an array
- Category
- Java
- Title
- store string elements in character array in java
- Category
- Java
- Title
- how to make an arraylist java
- Category
- Java
- Title
- string to int java
- Category
- Java
- Title
- remove first character from string
- Category
- Java
- Title
- hibernate onetone with mapsid
- Category
- Java
- Title
- java syntax
- Category
- Java
- Title
- hide elements android
- Category
- Java
- Title
- java beginners book
- Category
- Java
- Title
- taking string input in java
- Category
- Java
- Title
- string to double java
- Category
- Java
- Title
- spring framework iterate
- Category
- Java
- Title
- spigot custom join message
- Category
- Java
- Title
- even or odd in java
- Category
- Java
- Title
- faire un timer en java
- Category
- Java
- Title
- android elevation not working
- Category
- Java
- Title
- how to initialize main in java
- Category
- Java
- Title
- how to minimize jframe in java
- Category
- Java
- Title
- What is returned by a producer.send() call in the Java API? A boolean indicating if the call succeeded Future object Future object Unit
- Category
- Java
- Title
- how do I change the opacity of a JButton
- Category
- Java
- Title
- nextchar in java
- Category
- Java
- Title
- how to make it another player's turn java
- Category
- Java
- Title
- @fortawesome/free-solid-svg-icons
- Category
- Java
- Title
- creating array java
- Category
- Java
- Title
- how to create an array in java
- Category
- Java
- Title
- protect java
- Category
- Java
- Title
- how to get all the names of the files in a folder in java?
- Category
- Java
- Title
- eliminar fila jtable java
- Category
- Java
- Title
- java http interceptor
- Category
- Java
- Title
- iterate over map keys java
- Category
- Java
- Title
- java get environment variables
- Category
- Java
- Title
- java clear console
- Category
- Java
- Title
- java int passed by reference
- Category
- Java
- Title
- java connect to mysql
- Category
- Java
- Title
- working with buttons in applet java
- Category
- Java
- Title
- random boolean java
- Category
- Java
- Title
- java insert into arraylist
- Category
- Java
- Title
- random code
- Category
- Java
- Title
- java program to display characters from a to z using loop
- Category
- Java
- Title
- creating the functional interface in java
- Category
- Java
- Title
- how to detect if someone clicks on a jpanel in java
- Category
- Java
- Title
- treeset java descending order using comparator
- Category
- Java
- Title
- write an infinite loop java
- Category
- Java
- Title
- java int to hex fixed length
- Category
- Java
- Title
- java parse xml string
- Category
- Java
- Title
- how to check if a list is empty java
- Category
- Java
- Title
- how to read to into a file in java
- Category
- Java
- Title
- how to echo java_home in windows cmd
- Category
- Java
- Title
- java newinstance alternative
- Category
- Java
- Title
- else statement java
- Category
- Java
- Title
- compile java to jar in mac
- Category
- Java
- Title
- Enums injava
- Category
- Java
- Title
- java break in foreach
- Category
- Java
- Title
- get host from request object java
- Category
- Java
- Title
- Category
- Java
- Title
- javafx fill tableview with data
- Category
- Java
- Title
- isnumber java
- Category
- Java
- Title
- spigot action bar
- Category
- Java
- Title
- how to remove all special characters from a string in java
- Category
- Java
- Title
- How to make a class in Java?
- Category
- Java
- Title
- how to end a program in an if statement java
- Category
- Java
- Title
- Java int to roman
- Category
- Java
- Title
- how to add to a file in java
- Category
- Java
- Title
- processing pi
- Category
- Java
- Title
- déclarer un tableau en java
- Category
- Java
- Title
- string method example in java
- Category
- Java
- Title
- Java array nested equals
- Category
- Java
- Title
- para que sirve getcontentpane en java
- Category
- Java
- Title
- jstl core tags
- Category
- Java
- Title
- java instantiate collection with values
- Category
- Java
- Title
- java method
- Category
- Java
- Title
- loop array using stream java
- Category
- Java
- Title
- gson parse json
- Category
- Java
- Title
- java null pointer exception
- Category
- Java
- Title
- final variables in java
- Category
- Java
- Title
- java check if file exists
- Category
- Java
- Title
- Common GIt Commands
- Category
- Java
- Title
- how to create dynamic string array in java
- Category
- Java
- Title
- how to fill a list with a single value java
- Category
- Java
- Title
- java public static void main
- Category
- Java
- Title
- Filebody in java
- Category
- Java
- Title
- how to check type of primitive value in java
- Category
- Java
- Title
- file with line numbers inserted java
- Category
- Java
- Title
- get day name from date in java
- Category
- Java
- Title
- gat environment variables java
- Category
- Java
- Title
- java string to uuid
- Category
- Java
- Title
- array in line java
- Category
- Java
- Title
- java stack peek
- Category
- Java
- Title
- get sha key android
- Category
- Java
- Title
- java manacher's algorithm
- Category
- Java
- Title
- fragment manager in android
- Category
- Java