Question: You will not be required to write a recursive program. Your homework requires that you create a recursive method and that will be the extent
You will not be required to write a recursive program. Your homework requires that you create a recursive method and that will be the extent of our foray into recursion. Again, you need to understand how recursion works, but it is not widely used in the real world. Assignment: Create a Student class that will be used as your data record. The class contains instance variables for: student ID number, integer last name, string first name, string grade point average, double Build an application that will accept user input for your data record from the screen. Your program will create 3 files. The first file will contain records for honors students whose grade point average is at least 3.6 or higher. The second file will contain records for students in good standing with grade point averages between 2.0 and 3.5. The third file will contain records for students receiving probation with grade point averages below 2.0. Name your program SortStudents.java. Make sure there are several records in each file for later processing when you run your program. Create a second application that uses the files created above. Process each file in turn, beginning with the honors students, followed by the students in good standing and ending with the students receiving probation. Name your program StudentReport.java. Format your student report as follows: High Honors Students ID Number Name GPA 12345 Bill Johnson 3.8 23456 Judy Kirk 3.7 . . . Students in Good Standing ID Number Name GPA 34567 Suzy Clarkson 3.2 45678 Bob Wilson 2.9 56789 Mike Nice 2.5 . . . Students Receiving Probation ID Number Name GPA 67890 Diana Long 1.6 78901 Linda Willows 1.2 . . .
Finally, create a third application named SearchStudentFiles.java that will search the 3 files for a given students name. If the student is found, display the search results on the screen: ID Number Name GPA 67890 Diana Long 1.6 If the student is not found, display a message indicating so. Allow the user to perform multiple searches on the files, indicating they are done by entering a sentinel value as input.?
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
package com.rfp.classes;
import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.util.Scanner;
public class Student {
public int studentId; public String firstName; public String lastName; public double average;
public Student(int studentId, String firstName, String lastName, double average) { this.studentId = studentId; this.firstName = firstName; this.lastName = lastName; this.average = average; }
public int getStudentId() { return studentId; }
public void setStudentId(int studentId) { this.studentId = studentId; }
public String getFirstName() { return firstName; }
public void setFirstName(String firstName) { this.firstName = firstName; }
public String getLastName() { return lastName; }
public void setLastName(String lastName) { this.lastName = lastName; }
public double getAverage() { return average; }
public void setAverage(double average) { this.average = average; }
@Override public String toString() { return "studentId=" + studentId + ", firstName=" + firstName + ", lastName=" + lastName + ", average=" + average; }
@Override public int hashCode() { final int prime = 31; int result = 1; long temp; temp = Double.doubleToLongBits(average); result = prime * result + (int) (temp ^ (temp >>> 32)); result = prime * result + ((firstName == null) ? 0 : firstName.hashCode()); result = prime * result + (int) (temp ^ (temp >>> 32)); result = prime * result + ((lastName == null) ? 0 : lastName.hashCode()); result = prime * result + studentId; return result; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Student other = (Student) obj; if (Double.doubleToLongBits(average) != Double .doubleToLongBits(other.average)) return false; if (firstName == null) { if (other.firstName != null) return false; } else if (!firstName.equals(other.firstName)) return false; if (lastName == null) { if (other.lastName != null) return false; } else if (!lastName.equals(other.lastName)) return false; if (studentId != other.studentId) return false; return true; }
public void createFile(File file, Student s) throws IOException { FileWriter writer = new FileWriter(file);
String data = s.toString();
writer.write(data); writer.flush(); writer.close(); }
public static void main(String[] args) throws IOException { Scanner scanner = new Scanner(System.in); System.out.println("enter student no"); int no = scanner.nextInt(); System.out.println("enter your first name");
String fname = scanner.next();
System.out.println("enter your last name");
String lname = scanner.next(); System.out.println("enter your average"); double avg = scanner.nextDouble();
Student s = new Student(no, fname, lname, avg); File file = null; if (avg >= 3.6) {
file = new File("D:\\honourStudents.txt"); s.createFile(file, s); } if (avg >= 2.0 && avg <= 3.5) { file = new File("D:\\avgStudents.txt"); s.createFile(file, s); } if (avg < 2.0) { file = new File("D:\\lowavgStudents.txt"); s.createFile(file, s); }
}
}
output
enter student no 12345 enter your first name bob enter your last name d enter your average 3.8
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Just need to answer the bold section before the code
http://www.chegg.com/homework-help/questions-and-answers/written-java-java-assignment-required-write-recursive-program-homework-requires-create-rec-q18204946
This solution is incomplete. There is a part of the assignment that asks to create a third application named SearchStudentFiles.java that will search the 3 files for a given students name. If the student is found, display the search results on the screen. If the student is not found, display a message indicating so. Allow the user to perform multiple searches on the files, indicating they are done by entering a sentinel value as input. This is all missing from the answer given. Can someone answer this?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
