The following complete program contains a method that sums thenumbers 1-10; howe
ID: 3614858 • Letter: T
Question
The following complete program contains a method that sums thenumbers 1-10; however, thesum of those numbers does not display correctly inside main; changethe code so that main,
which calls the method, will display the sum properly. Themain method must not calculate the
sum but must output the sum. Do not use global variables aspart of your solution. Edit the
comments in the program to include the answer to the question posedby the comment.
public class Lab8_Ex1
{
public static void main(String [] args)
{
int sum = 0;
int n = 10;
compute_sum(n); // (1) What does this linerepresent?
System.out.println(“The sum is “ + sum);
System.exit(0);
}
public static void compute_sum(int x) // (2) What is this lineand
//the code that follows?
{
int sum = 0;
int num = 1;
while (num <=x)
{
sum += num;
num++;
}
}
}