Write a java program that will accept marks for 10 students who sat for a java examination. Total mark for the examination is 80. Determine the number of students who passed and failed the examination
import java.util.Scanner;
public class Answer {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int[] array = new int[10];
System.out.println("Enter marks for 10 students: ");
for (int i = 0; i < array.length; i++) {
array[i] = scanner.nextInt();
}
int ans = 0;
for (int a : array) {
if (a >= 80) {
ans++;
}
}
System.out.println("Number of students who passed: " + ans + " Number of failed students: " + (10 - ans));
}
}
Comments
Leave a comment