Class 11 Read Marks of Students from a Text File ISC 2020

a) A text file named “Student.txt” contains the students’ names (std) and marks (mks) of number of students.

Write a method to check and display the names of the students who have secured more than 75 marks.

The method declaration is as follows:

void check()

public static void check()throws IOException{
    FileReader fr = new FileReader("Student.txt");
    BufferedReader br = new BufferedReader(fr);
    String s = "";
    while((s = br.readLine()) != null){
        String std = s.substring(0, s.lastIndexOf(‘ ‘));
        int mks = Integer.parseInt(s.substring(s.lastIndexOf(' ') + 1));
        if(marks > 75)
            System.out.println(std);
    }
    br.close();
    fr.close();
}

b) State the significance of the statement:
FileWriter fileout = new FileWriter("Book.txt", true);
It signifies that an object named fileout of class FileWriter is created, to read a text file named “Book.txt”. The second parameter “true” means that the new content will be appended to the text file.

4 thoughts on “Class 11 Read Marks of Students from a Text File ISC 2020

  1. sir,a program is given which states that:
    A square matrix is said to be Magic Square matrix if sum of each row,each column and sum of diagonals are same.WAP in Java to accept size of matrix as ‘n’.Accept the array elements and check whether the matrix is magic square matrix or not.
    note:0<N<=5
    Eg:
    N=4
    Enter matrix elements:
    17
    24
    1
    8
    15
    23
    5
    7
    14
    16
    4
    6
    13
    20
    22
    10
    12
    19
    21
    3
    11
    18
    25
    2
    9
    ORIGINAL MATRIX:
    17 24 1 8 15
    23 5 7 14 16
    4 6 13 20 22
    10 12 19 21 3
    11 18 25 2 9
    IT IS A MAGIC SQUARE MATRIX.

    • You need to find the sum by accessing each row, column and diagonals, and check if the sum is same in all the dimensions. If you know how to access the elements, then this program should be easy for you.

Leave a Reply

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