Advertisement
sudoaptinstallname

Untitled

Jan 25th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. /*
  6. Amon Guinan
  7.  
  8. Friday, January 25.
  9. Program detects whether emails have a single "@" or not.
  10. */
  11. public class exercises {
  12. public static void main(String [] args)
  13. {
  14. int num;
  15.  
  16. System.out.println("Enter a number in base 10.");
  17. Scanner input = new Scanner(System.in);
  18. num = input.nextInt();
  19. int binary[] = new int[30];//[number] represents maximum array length.
  20. int index = 0;
  21. while(num > 0){
  22. binary[index++] = num%2;
  23. num = num/2;
  24. }
  25. for(int i = index-1;i >= 0;i--){
  26. System.out.print(binary[i]);
  27. }
  28. }
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement