write a command-line program which prompts the user for a series of decimal integer values separated by spaces. display each decimal integer along with its equivalent binary value. lease enter in a series of decimal values (separated by spaces):

Respuesta :

import java.util.*;

public class Main

{

   //  Convert the decimal number to a binary number

   static void DecimalToBinary(int num){

 String binary = ""; // Holds the binary value

 for (int i = num; i > 0; i /= 2) {

  binary = (i % 2) + binary;

 }

   System.out.println(num+" in binary is "+ binary);

   }

public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

       System.out.println("How many decimal number want to input ");

       int n=sc.nextInt();

       // Declaring and initializing an array of size 10

       int[] array = new int[n];

       int i;

       // Loop to store input values in nums array

       for (i = 0; i < array.length; i++) {

           array[i] = sc.nextInt();

       }

       for (i = 0; i < array.length; i++) {

           DecimalToBinary(array[i]);

       }

}

}

=>  DecimalToBinary() will convert decimal number to binary form.

=>  Input is taken from the user and they are added to the array and then element by element decimal number is converted into binary form.

=>  The above program will Display each decimal integer along with its equivalent binary value.

You can learn more about this at:

https://brainly.com/question/26803644#SPJ4