Java Program to convert from binary to decimal number
Input: 1111 //Binary Number
Output: 15 //Decimal Number
import java.io.*; import java.util.*; public class temp{ public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.println("Enter a Binary Number: "); String bin = scan.nextLine(); System.out.println("Decimal Number: "+Integer.parseInt(bin,2)); } }
INPUT_1:
Enter a Binary Number:
1101
OUTPUT:
Decimal Number: 13
INPUT_2:
Enter a Binary Number:
111
OUTPUT:
Decimal Number: 7
INPUT_3:
Enter a Binary Number:
0001
OUTPUT:
Decimal Number: 1
INPUT_4:
Enter a Binary Number:
1001
OUTPUT:
Decimal Number: 9
INPUT_5:
Enter a Binary Number:
1010
OUTPUT:
Decimal Number: 10
INPUT_6:
Enter a Binary Number:
1111
OUTPUT:
Decimal Number: 15
INPUT_7:
Enter a Binary Number:
010
OUTPUT:
Decimal Number: 2
ILLUSTRATION
Morae Q!
- Convert from binary number to decimal number.
- Swap two numbers by using division and multiplication.
- Compute foot and inches into centimetres.
- Concatenate Strings.
- Convert lowercase letters to uppercase letters.
- Compute the sum of all the digits of N.
- Compute the area of the pentagon.
- Get input using scanner.
- Find the distance between two points (x1,y1) and (x2,y2).
- Finding patterns in a file using frep and egrep .
- Detecting a cycle in a directed graph using Depth First Traversal.
- Topological ordering in a Graph.
- Storing graphs using adjacency list.
- Introduction to graph theory.
- Graph Adjacency Matrix pseudo code.
- Adjacency Matrix for storing graphs.
- Dijkstra’s shortest path algorithm .
- Breadth first search (BFS) Algorithm.
- Find the multiple of given number in the list of integers.
- Finding patterns in files using grep .