I have this Java programming assignment that I\'m working on and this I am suppo
ID: 3528392 • Letter: I
Question
I have this Java programming assignment that I'm working on and this I am suppose to have a while loop that will //increment the count by 1 //ask a user to input the score //add the score to the sum //get the score but I just tested the while loop and it says error please help with anything you can. import java.util.Scanner; public class Grade { public static void main(String args []) { Scanner k = new Scanner(System.in); int count = 0; int numOfStu = 0; int grade = 0; int sum = 0; double average; System.out.println ("How many students are there? "); numOfStu = k.nextInt(); System.out.println ("Number of students: " + numOfStu); count = 1 while ( <= numOfStu ) { System.out.println ("What is your score? "); sum = sum + grade grade = k.nextInt }Explanation / Answer
//pretty close, buy you lost some code and ; i think
import java.util.Scanner;
public class Grade {
public static void main(String args []) {
Scanner k = new Scanner(System.in);
int count = 0;
int numOfStu = 0;
int grade = 0;
int sum = 0;
double average;
System.out.println ("How many students are there? ");
numOfStu = k.nextInt();
System.out.println ("Number of students: "+ numOfStu);
count = 1;
while ( count <= numOfStu ) {
System.out.println ("What is your score? ");
grade = k.nextInt();
sum = sum + grade;
count = count +1;// increment count
}
average=sum/(double)numOfStu;
System.out.printf ("average: %.3f ", average);
k.close(); //close Scanner
}
}