Java code! A database is to be developed to keep track of student information at
ID: 3761063 • Letter: J
Question
Java code!
A database is to be developed to keep track of student information at your college. Their names, identification numbers, and grade point averages will be included. The data set will be accessed in the key field mode, with the student's name being the key field. Code a class named Listing that defines the nodes. The class must comply with the guidelines that permit student information nodes to be stored in the fully encapsulated BinaryTree structure. As such, your class should include all the methods in the class shown in Figure 2.16 and include a getKey method. Test it with a progressively developed driver program that demonstrates the functionality of all of its methods. When launched, the user will be presented with the following menu:
Enter:
1 to insert a new student's information,
2 to fetch and output a student's information,
3 to delete a student's information,
4 to update a student's information,
5 to output all the student information in descending order, and
6 to exit the program.
Figure 2.16:
Explanation / Answer
import java.io.*;
public class addstud {
public addstud()
{
}
public void addnew()throws Exception
{
BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
BufferedReader readFile=new BufferedReader(new FileReader("Studinfo.itp"));
BufferedWriter writeFile=new BufferedWriter(new FileWriter("Studinfo.itp",true));
String fn,cs;
System.out.println("Enter Student number:");
String sn=input.readLine();
System.out.println("Enter Fullname:");
fn=input.readLine();
System.out.println("Enter Course & Section");
cs=input.readLine();
int lineNum=0;
String line;
while((line=readFile.readLine())!=null)
{
lineNum++;
if(line.equals("Student number:" + sn))
{
System.out.println("Inputted student number already exists.");
break;
}
else
{
writeFile.newLine();
writeFile.write("Student number:" + sn);
writeFile.newLine();
writeFile.write("Fullname:" + fn);
writeFile.newLine();
writeFile.write("Course & Section:" + cs);
System.out.println(sn +" " + fn + " " + cs + " " + " student info successfully written to textfile.");
break;
}
}
writeFile.close();
readFile.close();
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.