Question

Project 2 Due April 15° 11:59pm. You could use an the implementation. y of the following programming language to do CH Java P
1 2 965 69 566 5669 5596 /9959/69996999/699/9 110/31/851/9271/52-4 91//81/232/0710/5/57 11262172211113391121 MM: F F F F M M
Project 2 Due April 15° 11:59pm. You could use an the implementation. y of the following programming language to do CH Java Python You will implement a student class with data members (ID, gender, DoB, Major, GPA). You will implement a gradebook class using (Inherit from) TWO of the following data structures. Array Singly Linked list ea Binary Search Tree You need to at least implement the followin gradebook. operations for the 1) FindHighestGPA0 returns the student who has the highest GPA 2) Insert insert a student record to the gradebook 3) Delete(studentID) delete a student record using student ID from the gradebook 4) Search(studentID) returns the student who has the student ID Test your code using the data in student data.txt. Import and parsing the data is suggested. DO NOT type in these data. Write an essay to discuss the advantages and disadvantages of using the Four data structures (Array, Singly Linked list, Heap, Binary Search Tree) to implement a student grade system considering the time efficiency and space efficiency You will do a 10 thoughts in the essay Submission check list mins presentation to demo your code and your 1. Source code [10 points] 2. Screenshots of test result and a document to explain your screenshots [10 points] 3. Essay [10 points] 4. Presentation PPT[10 points
1 2 965 69 566 5669 5596 /9959/69996999/699/9 110/31/851/9271/52-4 91//81/232/0710/5/57 11262172211113391121 MM: F F F F M M F F M M M F F M F F M 20 6562473 3162711982-121115242 STuh0a 4-9-7-5-4-1-0-2-9-3-0-0-8-1-3-9-2|8-4-8
0 0
Add a comment Improve this question Transcribed image text
Answer #1

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

Add a comment
Know the answer?
Add Answer to:
Project 2 Due April 15° 11:59pm. You could use an the implementation. y of the following programm...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a java code : Student ID at University is composed of year of admission and...

    Write a java code : Student ID at University is composed of year of admission and students number. we aim to implement a structure that improves operations of inserting and searching for a student. To enhance these operations, we will build a tree of linked lists (TreeOfLists) to combine advantages of both structures. Each node in this tree contains a linked list of all students who were admitted in that year. Each node in the linked list represents a student(id,...

  • Can you please help with the below? 1)   Which of the following is true about using...

    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.  ...

  • Project 4 simulation with conway's rules for life - revisited due before 4/30 11:59pm, autograded by...

    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...

  • 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

    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...

  • 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

    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...

  • You are asked to build and test the following system using Java and the object-oriented concepts ...

    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...

  • Instructions Part 1 - Implementation of a Doubly Linked List Attached you will find the code for ...

    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...

  • 1. State and explain the definition of big-O. 2. Explain why we use big-O to compare...

    1. State and explain the definition of big-O. 2. Explain why we use big-O to compare algorithms. 3. Explain why binary search runs in O(log n) time. 4. Under what conditions is it possible to sort a list in less than O(nlog n) time? 5. List and explain the worst-case and average-case running times for each Vector method below: (a) insert(iterator here, Object item) (b) insertAtHead (c) insertAtTail (aka push back) (d) get(iterator here) (e) get(index i) (f) remove(iterator here)...

  • Assignment #2: List - Array Implementation Review pages 6-7 in "From Java to C++" notes. Due...

    Assignment #2: List - Array Implementation Review pages 6-7 in "From Java to C++" notes. Due Friday, February 9th, 2017 @ 11:59PM EST Directions Create a List object. Using the following definition (List.h file is also in the repository for your convenience) for a list, implement the member functions (methods) for the List class and store the implementation in a file called List.cpp. Use an array to implement the list. Write the client code (the main method and other non-class...

  • C++ Assignment Project 1 - NodeList Building upon the the ListNode/List code I would like you...

    C++ Assignment Project 1 - NodeList Building upon the the ListNode/List code I would like you to extend the interface of a list to have these member functions as well. struct ListNode { int element; ListNode *next; } Write a function to concatenate two linked lists. Given lists l1 = (2, 3, 1)and l2 = (4, 5), after return from l1.concatenate(l2)the list l1should be changed to be l1 = (2, 3, 1, 4, 5). Your function should not change l2and...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT