Answer to Question #337687 in Java | JSP | JSF for Nene

Question #337687

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


1
Expert's answer
2022-05-05T14:02:25-0400
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));
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS