Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner;
- /*
- Amon Guinan
- Friday, January 25.
- Program detects whether emails have a single "@" or not.
- */
- public class exercises {
- public static void main(String [] args)
- {
- int num;
- System.out.println("Enter a number in base 10.");
- Scanner input = new Scanner(System.in);
- num = input.nextInt();
- int binary[] = new int[30];//[number] represents maximum array length.
- int index = 0;
- while(num > 0){
- binary[index++] = num%2;
- num = num/2;
- }
- for(int i = index-1;i >= 0;i--){
- System.out.print(binary[i]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement