Skip to content

Commit 8067bf2

Browse files
committed
day1Update
1 parent 5bd89c8 commit 8067bf2

File tree

8 files changed

+69
-0
lines changed

8 files changed

+69
-0
lines changed

bin/Day1/Binary2Octal.class

946 Bytes
Binary file not shown.

bin/Day1/GCD.class

643 Bytes
Binary file not shown.

bin/Day1/Octal2Binary.class

946 Bytes
Binary file not shown.

bin/Day1/decimal2Binary.class

952 Bytes
Binary file not shown.

src/Day1/Binary2Octal.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package Day1;
2+
3+
import java.util.Scanner;
4+
5+
public class Binary2Octal {
6+
7+
public static void main(String[] args) {
8+
9+
Scanner sc = new Scanner(System.in);
10+
11+
String a = sc.nextLine();
12+
13+
int b = Integer.parseInt(a, 2);
14+
15+
String octal = Integer.toOctalString(b);
16+
17+
System.out.println(octal);
18+
}
19+
}

src/Day1/GCD.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package Day1;
2+
3+
public class GCD {
4+
5+
private static int GCD1(int a, int b) {
6+
if (b == 0)
7+
return a;
8+
else
9+
return GCD1(b, a % b);
10+
}
11+
12+
public static void main(String[] args) {
13+
14+
System.out.println(GCD1(20, 20));
15+
}
16+
}

src/Day1/Octal2Binary.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package Day1;
2+
3+
import java.util.Scanner;
4+
5+
public class Octal2Binary {
6+
7+
public static void main(String[] args) {
8+
9+
Scanner sc = new Scanner(System.in);
10+
String a = sc.nextLine();
11+
int b = Integer.parseInt(a, 8);
12+
String bin = Integer.toBinaryString(b);
13+
System.out.println(bin);
14+
}
15+
}

src/Day1/decimal2Binary.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package Day1;
2+
3+
import java.util.Scanner;
4+
5+
public class decimal2Binary {
6+
7+
public static void main(String[] args) {
8+
9+
Scanner sc = new Scanner(System.in);
10+
11+
String a = sc.nextLine();
12+
13+
int b = Integer.parseInt(a, 10);
14+
15+
String bin = Integer.toBinaryString(b);
16+
17+
System.out.println(bin);
18+
}
19+
}

0 commit comments

Comments
 (0)