Question: This program accepts, as input two integers. (the first is less than the second). It then passes these to a method called AddRange which prints
This program accepts, as input two integers. (the first is less than the second). It then passes these to a method called AddRange which prints the sum of the integers from the first to the second (inclusive). For example, if the integers are 4 and 8 the METHOD will print
4+5+6+7+8=30
I have written the main method for you, you need to write the AddRange method.
import java.util.Scanner; public class Number3 {
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); } } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
