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

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 answer it using java?

the input: 4 6 5 10 4 4 the output should be like this: Enter the first integer Enter the second integer 4 + 5 + 6 = 15 Enter the first integer Enter the second integer 5 + 6 + 7 + 8 + 9 + 10 = 45 Enter the first integer Enter the second integer

Please DO NOT answer this answer it does not work. It gave error L14Number4.java:8: error: incompatible types: int cannot be converted to boolean while(1) ^ L14Number4.java:19: error: cannot find symbol AddRange(num1, num2); ^ symbol: method AddRange(int,int) location: class L14Number4 2 errors.

import java.util.Scanner;

public class L14Number4 {

public static void main(String[] args) {

Scanner keyboard=new Scanner(System.in);

int num1, num2;

while(true)

{

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);

}

}

}

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!