Attendance Percentage Calculator
Calculate attendance percentage and decide if a student is allowed to sit in exam.
BeginnerTopic: Module 2: Conditional Programs
Java Attendance Percentage Calculator Program
This program helps you to learn the fundamental structure and syntax of Java programming.
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
Understanding Attendance Percentage Calculator
We compute attendance percentage and compare with a threshold (75%).
Note: To write and run Java programs, you need to set up the local environment on your computer. Refer to the complete article Setting up Java Development Environment. If you do not want to set up the local environment on your computer, you can also use online IDE to write and run your Java programs.