write a Java program that will: Create an array to hold 20 student exam scores (
ID: 3688965 • Letter: W
Question
write a Java program that will:
Create an array to hold 20 student exam scores (ints)
Use a for-loop to ask the user for each score and read them into the array
AFTER the for-loop (after all scores are stored in the array), do the following:
Declare a count variable and initialize it to 0
Use a for-loop to help you count how many students in the array passed the exam (where 60 and higher is considered passing)
Add one to your count every time you find a passing score
Display the count after the loop.
Explanation / Answer
class Marks{
public static void main(String[] args) {
int count=0;
int[] numbers = new int[21];
for ( int i = 0; i <=20; i++)
{
System.out.println("Enter the marks of students:");
numbers[i] = i;
if(number[i]>=60)
{
count=count+1;
}
}
System.out.println("The total number of students passed in the class are :"+count);
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.