Skip to content

Commit fe7ce9a

Browse files
author
Bhatt-Darshan
committed
added java with digital number syatem
1 parent d3ccbf8 commit fe7ce9a

File tree

3 files changed

+54
-4
lines changed

3 files changed

+54
-4
lines changed

java_basics/control_statement/src/If_else_ladder.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
2-
31
import java.util.Scanner;
42

53
public class If_else_ladder {
@@ -8,9 +6,9 @@ public static void main(String[] args) {
86

97
// if-else-if ladder Statement
108
try (Scanner scanner = new Scanner(System.in)) {
11-
9+
1210
long grade = scanner.nextLong();
13-
11+
1412
if (grade >= 90)
1513

1614
System.out.println("A++");
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>java_digital_number</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.jdt.core.javanature</nature>
16+
</natures>
17+
</projectDescription>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
2+
3+
public class NumberSystem {
4+
5+
public static void main(String[] args) {
6+
7+
String binary = "1000";
8+
9+
// binary String and Redix
10+
// Here Take Redix = 2 so String is Consider as Binary Number
11+
System.out.println(Integer.parseInt(binary, 2)); // Binary to Decimal
12+
13+
String octal = "0007";
14+
System.out.println(Integer.parseInt(octal, 8)); // Octal to Decimal
15+
16+
String hexaDecimal = "FFFF";
17+
System.out.println(Integer.parseInt(hexaDecimal, 16)); // HexaDecimal to Decimal
18+
19+
int decimal = 11;
20+
System.out.println(Integer.toBinaryString(decimal)); // Decimal to Binary
21+
22+
int decimalToOctal = 20;
23+
System.out.println(Integer.toOctalString(decimalToOctal)); // Decimal to Octal
24+
25+
int decimalToHex = 26;
26+
System.out.println(Integer.toHexString(decimalToHex)); // Decimal to HexaDecimal
27+
}
28+
29+
}
30+
/*
31+
* Redix = 2 : Take as Binary
32+
* Redix = 8 : Take as Octal
33+
* Redix = 16 : Take as HexaDecimal
34+
*
35+
*/

0 commit comments

Comments
 (0)