3. Write a program that will input ten grade of students. The passing grade is 75. Count and display the passed and failed grades. Use while / do while / for loop.

PHOTO EMBED

Sun Dec 08 2024 11:37:42 GMT+0000 (Coordinated Universal Time)

Saved by @John_Almer

package passedfailedgrades;
import java.util.Scanner;
public class PassedFailedGrades {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int passedCount = 0, failedCount = 0;

        for (int i = 1; i <= 10; i++) {
            System.out.print("Enter grade " + i + ": ");
            int grade = input.nextInt();

            if (grade >= 75) {
                passedCount++;
            } else {
                failedCount++;
            }
        }

        System.out.println("Passed: " + passedCount);
        System.out.println("Failed: " + failedCount);
    }
}
content_copyCOPY