Skip to content

Commit 7c3d545

Browse files
Add files via upload
1 parent 6d1e9ce commit 7c3d545

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

Number_Conversion_2.java

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
package basicjava;
3+
4+
import java.util.Scanner;
5+
6+
public class Number_Conversion_2 {
7+
public static void main(String[] args) {
8+
// Binary,Octal,Hexadecimal to Decimal
9+
Scanner input = new Scanner(System.in);
10+
11+
//Binary to decimal
12+
String binary = input.nextLine();
13+
Integer a = Integer.parseInt(binary, 2);
14+
System.out.println("a = "+a);
15+
16+
17+
//Octal to decimal
18+
String octal = input.nextLine();
19+
Integer a1 = Integer.parseInt(octal, 8);
20+
System.out.println("a = "+a1);
21+
22+
//Hexadecimal to decimal
23+
String hex = input.nextLine();
24+
Integer a2 = Integer.parseInt(hex, 16);
25+
System.out.println("a = "+a2);
26+
27+
}
28+
}

0 commit comments

Comments
 (0)