Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro SQL Server Administration

Authors: Peter Carter

1st Edition

1484207106, 9781484207109

More Books

Students also viewed these Databases questions

Question

=+2 Is the decision sustainable in the long run?

Answered: 1 week ago

Question

=+1 Is the decision fair to employees?

Answered: 1 week ago