Home work:-

Write a program to read 5 records consists of first name, last name, id and grade. Assign the grade according to the following specifications:
0<g<= 50 F
50<g<=60 D
60< g<= 70 C
70<g<=90 B
90<g <=100 A
Use Stringtokenizer and buffering to read your data then do proper parsing. Use Loop and Selection structure to complete the program.
The lowest grade is 20 and the highest is 100

Sure! I can help you with that. Here's an example of how you can write a program to read 5 records and assign grades based on the given specifications:

```java
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class GradeAssignment {

public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

for (int i = 0; i < 5; i++) {
System.out.println("Enter the student's first name:");
String firstName = reader.readLine();

System.out.println("Enter the student's last name:");
String lastName = reader.readLine();

System.out.println("Enter the student's ID:");
int id = Integer.parseInt(reader.readLine());

System.out.println("Enter the student's grade:");
int grade = Integer.parseInt(reader.readLine());

String assignedGrade = assignGrade(grade);

System.out.println("Student: " + firstName + " " + lastName);
System.out.println("ID: " + id);
System.out.println("Grade: " + assignedGrade);
System.out.println("----------------------------------");
}
}

public static String assignGrade(int grade) {
if (grade > 90 && grade <= 100) {
return "A";
} else if (grade > 70 && grade <= 90) {
return "B";
} else if (grade > 60 && grade <= 70) {
return "C";
} else if (grade > 50 && grade <= 60) {
return "D";
} else if (grade > 0 && grade <= 50) {
return "F";
} else {
return "Invalid grade";
}
}
}
```

Explanation:

1. We start by importing the necessary classes for input and error handling.
2. We create a class named `GradeAssignment` with the `main` method as the entry point of the program.
3. Inside the `main` method, we create an instance of `BufferedReader` to read input from the user.
4. We then use a `for` loop to iterate 5 times, allowing the user to enter information for each student.
5. Within each iteration, we prompt the user to enter the student's first name, last name, ID, and grade.
6. We parse the input using `Integer.parseInt` to convert the grade from a string to an integer.
7. We call the `assignGrade` method, which takes the grade as an argument and returns the assigned grade based on the given specifications.
8. We then print the student's information, including the assigned grade.
9. After printing the information, we add a separator to distinguish between each student's data.
10. The `assignGrade` method checks the given grade against the specifications using a series of `if-else` statements.
11. If the grade matches the specified range, the corresponding grade is returned. Otherwise, an "Invalid grade" message is returned.
12. Finally, the program execution ends.

You can run this program, and it will prompt you to enter the details for each student and display their assigned grades.