Java
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter total classes held: ");
int held = sc.nextInt();
System.out.print("Enter total classes attended: ");
int attended = sc.nextInt();
double per = (attended * 100.0) / held;
System.out.println("Attendance = " + per + "%");
if (per >= 75.0) {
System.out.println("Allowed to sit in exam");
} else {
System.out.println("Not allowed to sit in exam");
}
sc.close();
}
}Output
Enter total classes held: 100 Enter total classes attended: 80 Attendance = 80.0% Allowed to sit in exam
We compute attendance percentage and compare with a threshold (75%).