import java.util.Scanner;
class Hw05prog1
{
Run | Debug
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
//Take a variable n, it will store the number of students, store
int n=5;
//Create an integer array of size n
int[] scores=new int [n];
//First, print this heading
System.out.println(x:"This program calculates average score");
System.out.println(x:"----");
//Now, start a for loop, which iterates n number of times
for(int i=0;i<n; i++) {
//In each iteration ask user to enter the score of current stu
System.out.print("Enter the score for student "+(i+1)+" : ");
//Store, this user input in ith cell of scores array
scores [i]=sc.nextInt();
}
}
OUTPUT
Resource leak: 'sc' is never closed Java(536871799) [Ln 5, Col 17]