Question: Please complete the following code using JAVA program. I need the CODE and the SCREENSHOT of the program running. /* * To change this license

Please complete the following code using JAVA program. I need the CODE and the SCREENSHOT of the program running.

/*

* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.

*/

package decimaltobinary;

import java.util.Scanner;

/**

*

* @author Producer (Please put the name Samiha Riham at author Producer)

*/

public class DecimalToBinary {

/**

* @param args the command line arguments

*/

public static void main(String[] args) {

Scanner in = new Scanner(System.in);

System.out.println("Enter an integer between 1 and 100");

while(in.hasNextInt())

{

int a = in.nextInt();

while(a < 1 || a > 100)

{

System.out.println("Invalid number, please try again: ");

a = in.nextInt();

}

printBinary(a);

System.out.println(" Enter next number, q to exit");

}

}

private static void printBinary(int b)

{

}

}

Following c ode is for reference:

// Prints the given integer's binary representation.

// Precondition: n >= 0

public static void printBinary(int n) {

if (n < 2) {

// base case; same as base 10

System.out.println(n);

} else {

// recursive case; break number apart

printBinary(n / 2);

printBinary(n % 2);

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!