hi, i'm trying to write a programme that reads two integers, and outputs the sum of all even numbers between that range e.g 10 14 = 36 (10+12+14)
here is what i have so far, but i have messed up the calculation somewhere, any help would be greatly appreciated, thankyou
import java.util.Scanner; public class Rangefinder { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int num1, num2, min, max, amt = 0; System.out.println("Please enter two integers: "); num1 = scan.nextInt(); num2 = scan.nextInt(); min = Math.min(num1, num2); max = Math.max(num1, num2); for (int x = min; x <= max; x++) { amt = amt + x; } System.out.println(amt); } }