Class 11

Read Attendance from a Text File in Java

A text file named “attend.txt” contains the name (emp) and attendance (atd) of a number of employees.

Write a program to display the names of the employees whose attendance is more than 80 days.

The sample datain the text file could be in the following format:

Sundar Pichai 92
Satya Nadella 75
Bill Gates 82
class Attendance{
    public static void main(String args[])throws IOException{
        FileReader fr = new FileReader("attend.txt");
        BufferedReader br = new BufferedReader(fr);
        String s = new String();
        while((s = br.readLine()) != null){
            String emp = s.substring(0, s.lastIndexOf(' '));
            int atd = Integer.parseInt(s.substring(s.lastIndexOf(' ') + 1));
            if(atd > 80)

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.