Skip to content

Commit 137a882

Browse files
authored
Create DecimalToBinary.java
1 parent 91bee0d commit 137a882

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Moderate-Level/DecimalToBinary.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
You are given a decimal (base 10) number, print its binary representation.
3+
*/
4+
5+
import java.io.*;
6+
public class Main {
7+
public static void main (String[] args) throws IOException {
8+
File file = new File(args[0]);
9+
BufferedReader br = new BufferedReader(new FileReader(file));
10+
String line;
11+
while ((line = br.readLine()) != null) {
12+
int a = Integer.parseInt(line);
13+
System.out.println(Integer.toBinaryString(a));
14+
}
15+
br.close();
16+
}
17+
}

0 commit comments

Comments
 (0)