Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Here\'s the code I wrote: import java.util.*; public class normal { public stati

ID: 3611537 • Letter: H

Question

Here's the code I wrote:
import java.util.*;
public class normal
{
public static void main (String args[])
{
Scanner scan = new Scanner(System.in);

System.out.println("Enter total of numbers to be added: ");
int total = scan.nextInt();

System.out.println("Enter next data items: ");
int data = scan.nextInt();

int count = 0;
for (int i = 1; i <= total; i++);

{
data = scan.nextInt();
count = data + count;
}

double calculate = (double)(count/total);
System.out.println("Average of total numbers is: " +calculate);

}
}

The output is totally off.

An example of the outprint from command line after compile:

Enter total of numbers to be added: 5
Enter next data items:
0
20
Average of total number is: 4.0

Strange as to why the program just stops after I input 2 items ofnumbers, 0 and 20 , then exit out of the loop and performs theSystem.out.println calculation. I feel it should loop fromthe structure
for (int i =1; i<=5; i++);



Explanation / Answer

for (int i = 1; i <= total; i++); remove the semi colan after the for statement