Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Add a loop to main in #3. You should continue to get integers from the user unti

ID: 3734642 • Letter: A

Question

Add a loop to main in #3. You should continue to get integers from the user until the user gives you a first number that is greater than or equal to the second.

import java.util.Scanner;
public class L14Number4 {

  
public static void main(String[] args) {
Scanner keyboard=new Scanner(System.in);
int num1, num2;
  
  
System.out.println("Enter the first integer");
num1=keyboard.nextInt();
System.out.println("Enter the second integer");
num2=keyboard.nextInt();
AddRange(num1, num2);
}

}
}

Can anyone help me to finger out the answer using java?

Explanation / Answer

import java.util.Scanner;

public class L14Number4 {

  

public static void main(String[] args) {

Scanner keyboard=new Scanner(System.in);

int num1, num2;

  

while(1)

{

System.out.println("Enter the first integer");

num1=keyboard.nextInt();

System.out.println("Enter the second integer");

num2=keyboard.nextInt();

if(num1 >= num2)

break;

AddRange(num1, num2);

}

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote