Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You have to build from the classes I pasted at the very bottom. Here is the assi

ID: 3827421 • Letter: Y

Question

You have to build from the classes I pasted at the very bottom. Here is the assignment:

public class Student
{
private String fname, lname;
private int grade;
  
public Student(String fname, String lname, int grade)
{
this.fname = fname;
this.lname = lname;
this.grade = grade;
}

public String toString()
{
return fname + " " + lname + " " + grade;
}
}

import java.util.Scanner;
import java.io.*;

public class Students
{
public static void main (String[] args) throws IOException
{ String first_name, last_name;
int grade, total=0, count=0;
double average;
Scanner fileInput = new Scanner(new File("students.txt"));
while (fileInput.hasNext())
{
first_name = fileInput.next();
last_name = fileInput.next();
grade = fileInput.nextInt();
  
Student st = new Student(first_name, last_name, grade);
  
System.out.println(st);
total = total + grade;
count++;
}
average = (double)total/count;
System.out.println("There are " + count + " students with average grade " + average);
}
}

Write a program in Java and run it in BlueJ according to the following specifications: The program reads a text file with student records (first name, last name and grade). Then it prompts the user to enter acommand, executes the command and loops. The commands are the following: "printall prints all student records rst name, last name, grade o "firstname name" prints all students with first name that starts with the provided parameter name. o "lastname name" prints all students with first name that starts with the provided parameter name. interval m n" prints all students with grades in the interval Km, n end exits the loop the terminates the program. For example, if the input text file is students.txt and the user enters "printal he program prints the following John Smith 90 Barack Obama 95 Al Clark 80 Sue Taylor 55 Ann Miller 75 George Bush 58 John Miller 65 If the user enters "firstname A the program prints the following Al Clark 80 Ann Miller 75 If the user enters "lastname Miller" the program prints the following Ann Miller 75 John Miller 65 If the user enters "interval 7590 the program prints the following John Smith 90 Al Clark 80 Ann Miller 75 Requirements and restrictions: 1. Use the Student java and Students java classes from the course website to represent and process student records and modify them accordingly: Define and use an array of objects of class Student to store all student records read from the file o In class Students define the following methods that accept the array of students and other proper parameters and do the following Prints all student records in the array. Prints all students with first name that starts with the provided parameter. Hint: use the indexOf(String str) method form class String o Prints all students with last that starts with the provided parameter. Hint: use the indexOf(String str method form class String prints all students with grades in the interval [m, nj Do NOT use the array of Students directly in the main method, all processing must be done by the methods described above using the array passed to them as a parameter. o Enforce the encapsulation principle. o No need to verify the user input.

Explanation / Answer

HI, Please find my modification.

Please let me know in case of any issue.

#######

public class Student
{
   private String fname, lname;
   private int grade;

   public Student(String fname, String lname, int grade)
   {
       this.fname = fname;
       this.lname = lname;
       this.grade = grade;
   }
   public String toString()
   {
       return fname + " " + lname + " " + grade;
   }
   public String getFname() {
       return fname;
   }
   public String getLname() {
       return lname;
   }
   public int getGrade() {
       return grade;
   }
   public void setFname(String fname) {
       this.fname = fname;
   }
   public void setLname(String lname) {
       this.lname = lname;
   }
   public void setGrade(int grade) {
       this.grade = grade;
   }


}

#########

import java.util.Scanner;

import java.io.*;

public class Students

{

   public static void printAllStudent(Student[] arr, int n){

       for(int i=0; i<n; i++)

           System.out.println(arr[i]);

   }

   public static void printStartsWithFirst(Student[] arr, int n, String start){

       for(int i=0; i<n; i++){

           if(arr[i].getFname().startsWith(start)){

               System.out.println(arr[i]);

           }

       }

   }

   public static void printStartsWithLast(Student[] arr, int n, String start){

       for(int i=0; i<n; i++){

           if(arr[i].getLname().startsWith(start)){

               System.out.println(arr[i]);

           }

       }

   }

   public static void printInInterval(Student[] arr, int n, int l, int h){

       for(int i=0; i<n; i++){

           if(arr[i].getGrade() >= l && arr[i].getGrade() <= h){

               System.out.println(arr[i]);

           }

       }

   }

   public static void main (String[] args) throws IOException

   { String first_name, last_name;

   int grade, total=0, count=0;

   //double average;

   Scanner fileInput = new Scanner(new File("students.txt"));

   Student arr[] = new Student[100];

   while (fileInput.hasNext())

   {

       first_name = fileInput.next();

       last_name = fileInput.next();

       grade = fileInput.nextInt();

       Student st = new Student(first_name, last_name, grade);

       arr[count]= st;

       //System.out.println(st);

       //total = total + grade;

       count++;

   }

   //average = (double)total/count;

   //System.out.println("There are " + count + " students with average grade " + average);

   }

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote