Last active
June 27, 2023 05:38
-
-
Save pmatsinopoulos/1738d8d18bd2217807c5c2e4b71e9a58 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class IntegerToBinary { | |
public static void main(String[] args) { | |
System.out.print("Give me an integer number: "); | |
Scanner scanner = new Scanner(System.in); | |
if (scanner.hasNextInt()) { | |
int integer = scanner.nextInt(); | |
System.out.printf("Binary: %s\n", Integer.toString(integer, 2)); | |
} | |
scanner.close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment