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

So i need to read a text file consisting of student records (name,address,studen

ID: 3869094 • Letter: S

Question

So i need to read a text file consisting of student records (name,address,student id).I need each individual word stored in a variable. For example, johnny needs to be stored in name, 123 wonderworld drive in address, and 1234 in student id. I need to read the file and place them into a vector sorted by id. My question is how do i easily read the text from the file in place into a vector? I am doing this in c++.

Here is my detailed instructions for the project.

Here is a sample of the text file.

- Create a file of at least 20 student records sorted by student ID. Read student records into a vector in C+or Java program. (For Vector, refer to Chapter 7.11) Student records should include Student ID, Name, GPA, Student Address, and a pointer which points to (10+) test scores for each student record located in the program or from a second file. - Display the 20+ student records (entire record, not just ID) and associated test scores. Use recursive binary search to search three-five student-IDs in the vector. Use recursive binary search to search a student-ID at the end of the vector. Use recursive binary search to search a student-ID which is not in the vector For each search, print the ID to be searched and the searched result with the found entire record. . - Your program output must show proper information to be understood well by the reader/viewer

Explanation / Answer

import java.io.*;
2 import java.util.*;
3
4 class Students
5 {
6 // Read a number of Student records from a file, store them in an array
7
8 static final int MAXSTUDENTS=100;
9 static final int MAXMARKS=30;
10
11 public static void main(String[] args) throws IOException
12 {
13 String filename;
14 Student [] data;
15 int count=0;
16 BufferedReader in = Text.open(System.in),inFile;
17 for(;;)
18 try
19 {
20 System.out.print(" Enter file name to read from: ");
21 filename=Text.readString(in);
22 inFile=Text.open(filename);
23 break;
24 }
25 catch(FileNotFoundException e)
26 {
27 System.out.println("No file of that name found");
28 }
29 data = new Student[MAXSTUDENTS];
30 try
31 {
32 for(;;)
33 try
34 {
35 data[count++] = readStudent(inFile);
36 }
37 catch(PersonException e)
38 {
39 System.out.println(e.getMessage());
40 count--;
41 }
42 }
43 catch(IOException e)
44 {
45 }
46 catch(ArrayIndexOutOfBoundsException e)
47 {
48 System.out.print("Maximum number of students ("+MAXSTUDENTS);
49 System.out.println(") exceeded");
50 }
51 count--;
52 new PeopleSorter(new PeopleOrderByName()).sort(data,count);
53 System.out.println(" The records are: ");
54 for(int i=0;i<count;i++)
55 System.out.println(data[i]);
56 }
57
58 public static Student readStudent(BufferedReader reader)
59 throws IOException,PersonException
60 {
61 int day,month,year,numMarks;
62 String name,marksString,dateString,nameString,firstNames;
63 StringTokenizer tokens;
64 int[] marks;
65 nameString=reader.readLine();
66 if(nameString==null)
67 throw new IOException();
68 tokens = new StringTokenizer(nameString);
69 firstNames = tokens.nextToken();
70 name=tokens.nextToken();
71 while(tokens.hasMoreTokens())
72 {
73 firstNames+=" "+name;
74 name=tokens.nextToken();
75 }
76 dateString=reader.readLine();
77 tokens = new StringTokenizer(dateString,"/");
78 day=Integer.parseInt(tokens.nextToken());
79 month=Integer.parseInt(tokens.nextToken());
80 year=Integer.parseInt(tokens.nextToken());
81 marks = new int[MAXMARKS];
82 marksString=reader.readLine();
83 tokens = new StringTokenizer(marksString);
84 numMarks=0;
85 while(tokens.hasMoreTokens())
86 marks[numMarks++]=Integer.parseInt(tokens.nextToken());
87 return new Student(day,month,year,name,firstNames,numMarks,marks);
88 }
89
90 }
import java.io.*;
2
3 class Students4
4 {
5 // Read a number of Student records from a file, store them in an array
6 // Filter out those whose average mark is below an input figure
7
8 static final int MAXSTUDENTS=100;
9 static final int MAXMARKS=30;
10
11 public static void main(String[] args) throws IOException
12 {
13 String filename;
14 Student [] data;
15 int count=0;
16 double passMark;
17 BufferedReader in = Text.open(System.in),inFile;
18 for(;;)
19 try
20 {
21 System.out.print(" Enter file name to read from: ");
22 filename=Text.readString(in);
23 inFile=Text.open(filename);
24 break;
25 }
26 catch(FileNotFoundException e)
27 {
28 System.out.println("No file of that name found");
29 }
30 data = new Student[MAXSTUDENTS];
31 try
32 {
33 for(;;)
34 try
35 {
36 data[count++] = Student.read(inFile);
37 }
38 catch(PersonException e)
39 {
40 System.out.println(e.getMessage());
41 count--;
42 }
43 }
44 catch(IOException e)
45 {
46 }
47 catch(ArrayIndexOutOfBoundsException e)
48 {
49 System.out.print("Maximum number of students ("+MAXSTUDENTS);
50 System.out.println(") exceeded");
51 }
52 count--;
53 System.out.println(" The records are: ");
54 for(int i=0;i<count;i++)
55 System.out.println(data[i]);
56 System.out.print("Enter pass mark: ");
57 passMark=Text.readDouble(in);
58 PeopleFilter myFilter =
59 new PeopleFilter(new StudentChooseByHighAverageMark(passMark));
60 count=myFilter.filter(data,count);
61 System.out.println(" The records of those who have passed are: ");
62 for(int i=0;i<count;i++)
63 System.out.println(data[i]);
64 }
65
66 }

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