We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 91bee0d commit 137a882Copy full SHA for 137a882
Moderate-Level/DecimalToBinary.java
@@ -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