Conversion from binary to decimal

 Conversion from binary to decimal

Problem Description


Java Program to convert from binary to decimal number

Logic Test Case 1


Input (stdin)

1101


Expected Output


13

Logic Test Case 2


Input (stdin)

111


Expected Output


7



CODE AREA

import java.io.*;

import java.util.*;

public class TestClass {

public static void main(String[] args) { 

       Scanner input = new Scanner( System.in );

       //System.out.print("Enter a binary number: ");

       String binaryString =input.nextLine();

       System.out.println(Integer.parseInt(binaryString,2));

 

}

}

Post a Comment

0 Comments