Question: J DebugTwelve2.java X DV J DebugTwelve2.java > DebugTwelve2 > main(String) // User enters a number 2 // Program computes sum of all numbers between 3

J DebugTwelve2.java X DV J DebugTwelve2.java > DebugTwelve2 > main(String) // User enters a number 2 // Program computes sum of all numbers between 3 // that number and the number 5 greater 4 import java. util. Scanner; 5 public class DebugTwelve2 6 7 public static void main(String[ ] args) 8 9 Scanner input = new Scanner(System. in) ; 10 int x; 11 final int GAP = 5; 12 int answer ; 13 String userInput; 14 System. out . print ("Enter a number > > "); 15 userInput = input. nextLine( ); 16 x = Integer . parseIn 17 y = x + GAP; GASP GAPE GPA 18 answer = sum (x, GAP ) ; 19 System. out . printIn("The sum of all the numbers between ") ; 20 System. out . printIn(" "+ x + " and " + y + " is " + an 21 22 public static int sum(int x, int y) 23 I 24 if (y > x ) 25 return(sum(x, y - 1) ); 26 else 27 return x; 28 29 3 Java: Lightweight Mode Ln 18, Col 26 Spaces
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
