
Student.java
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.LinkedList;
import java.util.Scanner;
public class Student {
LinkedList<StudentDetails> linkedList = new
LinkedList<>();
final String fileName = "data.txt";
File file = new File(fileName);
static FileWriter fileWriter;
void readFile() throws IOException {
File file = new
File(fileName);
BufferedReader br = new BufferedReader(new FileReader(file));
String str;
while ((str =
br.readLine()) != null ) {
String arr[] =
str.split(" ");
linkedList.add(new StudentDetails(arr[0], arr[1], arr[2], arr[3],
Float.parseFloat(arr[4])));
}
}
void writeToFile(String data) {
try {
if(fileWriter==null)
fileWriter = new FileWriter(file);
fileWriter.write(data+"\n");
fileWriter.flush();
} catch (IOException e) {
e.printStackTrace();
}
}
void findHighestGPA() {
float highestGPA =
linkedList.get(0).getGPA();
for (int i = 1; i <
linkedList.size(); i++) {
if
(linkedList.get(i).getGPA() > highestGPA) {
highestGPA = linkedList.get(i).getGPA();
}
}
System.out.println("Higest GPA is "
+ highestGPA);
}
void delete(String studentID) {
for (int i = 0; i <
linkedList.size(); i++) {
if
(linkedList.get(i).getID().equalsIgnoreCase(studentID)) {
linkedList.remove(i);
System.out.println("Data removed");
}
}
}
void search(String studentID) {
for (int i = 0; i <
linkedList.size(); i++) {
if
(linkedList.get(i).getID().equalsIgnoreCase(studentID))
{
System.out.println(linkedList.get(i).toString());
}
}
}
public static void main(String[] args)
throws IOException {
Scanner scanner = new
Scanner(System.in);
String ID, gender, DoB,
Major;
float GPA;
Student student = new
Student();
student.readFile(); // read file and add data to
linked list for further easily processing
char ch = 0;
do {
System.out.println("1.Find highest GPA ");
System.out.println("2.Insert data ");
System.out.println("3.Delete data ");
System.out.println("4.Search data ");
int n =
scanner.nextInt();
switch (n)
{
case 1:// find
highest Gpa
student.findHighestGPA();
break;
case 2://
insert
System.out.println("Enter student ID ");
ID = scanner.next();
System.out.println("Enter student gender
");
gender = scanner.next();
System.out.println("Enter student DoB ");
DoB = scanner.next();
System.out.println("Enter student Major
");
Major = scanner.next();
System.out.println("Enter student GPA ");
GPA = scanner.nextFloat();
String data = ID + " " + gender + " " + DoB + "
" + Major + " " + GPA;
student.writeToFile(data);
student.linkedList.clear();
student.readFile(); // read file and add data to
linked list for further easily processing
break;
case 3://
delete
System.out.println("Enter student ID ");
student.delete(scanner.next());
break;
case 4://
search
System.out.println("Enter student ID ");
student.search(scanner.next());
break;
}
System.out.println("Do you want to continue? ");
ch =
scanner.next().charAt(0);
} while (ch == 'Y' || ch ==
'y');
// close the file as program is terminating
student.fileWriter.close();
}
// Model or POJO class
class StudentDetails {
private String ID, gender, DoB,
Major;
private float GPA;
public
StudentDetails(String iD, String gender, String doB, String major,
float gPA) {
setID(iD);
setGender(gender);
setDoB(doB);
setMajor(major);
setGPA(gPA);
}
public String getID()
{
return ID;
}
public void setID(String
iD) {
ID = iD;
}
public String
getGender() {
return
gender;
}
public void
setGender(String gender) {
this.gender =
gender;
}
public String getDoB()
{
return
DoB;
}
public void
setDoB(String doB) {
DoB = doB;
}
public String getMajor()
{
return
Major;
}
public void
setMajor(String major) {
Major =
major;
}
public float getGPA()
{
return
GPA;
}
public void setGPA(float
gPA) {
GPA = gPA;
}
@Override
public String toString() {
return ID + " "
+ gender + " " + DoB + " " + Major + " " + GPA;
}
}
}
Output
1.Find highest GPA
2.Insert data
3.Delete data
4.Search data
2
Enter student ID
JU-3
Enter student gender
M
Enter student DoB
19/12/95
Enter student Major
CS
Enter student GPA
60
Do you want to continue?
y
1.Find highest GPA
2.Insert data
3.Delete data
4.Search data
1
Higest GPA is 60.0
Do you want to continue?
y
1.Find highest GPA
2.Insert data
3.Delete data
4.Search data
4
Enter student ID
ju-3
JU-3 M 19/12/95 CS 60.0
Do you want to continue?
y
1.Find highest GPA
2.Insert data
3.Delete data
4.Search data
3
Enter student ID
ju-3
Data removed
Do you want to continue?
y
1.Find highest GPA
2.Insert data
3.Delete data
4.Search data
4
Enter student ID
Ju-3
Do you want to continue?
n
Project 2 Due April 15° 11:59pm. You could use an the implementation. y of the following programm...
Project 4 simulation with conway's rules for life - revisited due before 4/30 11:59pm, autograded by project 4 zylab, limited to 10 submissions. We will be using the concepts from project 2 to test the more recent concepts of linked lists, pointers, and file I/O. The initial data points will be stored in a file (specification of the layout of the file below), each grid of values will be dynamically allocated and then referenced via a pointer in a linked...
You are asked to build and test the following system using Java and the object-oriented concepts you learned in this course: Project (20 marks) CIT College of Information technology has students, faculty, courses and departments. You are asked to create a program to manage all these information's. Create a class CIT to represents the following: Array of Students, each student is represented by class Student. Array of Faculty, each faculty is represented by class Faculty. Array of Course, each course...
Hw08FinalProjectStudentList.txt: (Data structure is
Array List)
1,Simon,Jefferson,gy3085,4.0,2019
2,John,Johnson,xy1242,3.9,2019
3,Kayla,Anderson,as1324,3.8,2019
4,David,Kidman,re5423,3.8,2017
5,Mary,Coleman,ze7698,3.8,2018
Description: This assignment is going to evaluate your overall knowledge of the Java Programming. You shall implement a program which can store and retrieve student list. The program has a menu that you can take input from console, and the user can choose between the items. The program data is in the HwO8FinalProjectStudentList.txt file. Required Items: 1. The program must show a menu to user and ask the user...
Can you please help with the below? 1) Which of the following is true about using a 2-3-4 tree? a. It is designed to minimize node visits while keeping to an O(log n) search performance b. It is designed to self-balance as new values are inserted into the tree c. As soon as a node becomes full, it performs the split routine d. None of the above 2) Which of the following is true about a binary search tree? a. ...
Hw08FinalProjectStudentList.txt
1,Simon,Jefferson,gy3085,4.0,2019
2,John,Johnson,xy1242,3.9,2019
3,Kayla,Anderson,as1324,3.8,2019
4,David,Kidman,re5423,3.8,2017
5,Mary,Coleman,ze7698,3.8,2018
Description: This assignment is going to evaluate your overall knowledge of the Java Programming. You shall implement a program which can store and retrieve student list. The program has a menu that you can take input from console, and the user can choose between the items. The program data is in the HwO8FinalProjectStudentList.txt file. Required Items: 1. The program must show a menu to user and ask the user can either choose between the...
Instructions Part 1 - Implementation of a Doubly Linked List Attached you will find the code for an implementation of a Singly Linked List. There are 3 files: Driver.java -- testing the List functions in a main() method. LinkNode.java -- Class definition for a Node, which is the underlying entity that stores the items for the linked list. SinglyLinkedList.java -- Class definition for the Singly Linked List. All the heavy lifting happens here. Task 1 - Review & Testing: Create...
Instructions Part 1 - Implementation of a Doubly Linked List Attached you will find the code for an implementation of a Singly Linked List. There are 3 files: Driver.java -- testing the List functions in a main() method. LinkNode.java -- Class definition for a Node, which is the underlying entity that stores the items for the linked list. SinglyLinkedList.java -- Class definition for the Singly Linked List. All the heavy lifting happens here. Task 1 - Review & Testing: Create...
python 3 question Project Description Electronic gradebooks are used by instructors to store grades on individual assignments and to calculate students’ overall grades. Perhaps your instructor uses gradebook software to keep track of your grades. Some instructors like to calculate grades based on what is sometimes called a “total points” system. This is the simplest way to calculate grades. A student’s grade is the sum of the points earned on all assignments divided by the sum of the points available...
This is in C. For this assignment we will write a simple database server. We will be creating a simple database of student records, so let’s describe these first. The format of a student record is as follows: typedef struct student { char lname[ 10 ], initial, fname[ 10 ]; unsigned long SID; float GPA; } SREC; Part One – the Server We will create a database server. The job of the server is to accept a...
using java to write,show me the output. please write some
common.
You CAN NOT use inbuild functions for Tree ADT operations.
using code below to finsih
public class Main
{
public static void main(String[] args) {
BinaryTree tree = new
BinaryTree();
tree.root = new Node(1);
tree.root.left = new Node(2);
tree.root.right = new Node(3);
tree.root.left.left = new Node(4);
tree.root.left.right = new Node(5);
tree.root.right.left = new Node(6);
tree.root.right.right = new Node(7);
tree.root.left.left.left = new Node(8);
tree.root.left.left .right= new Node(9);...