تم الحل ✓
categoryهندسة الحاسبات
schoolبكالوريوس
event_available2026-07-15
السؤال
Transcribed Image Text:
Program Description:
Write a program to save a list of student records and then perform several operations on this
list. Your program will take two text files as input.
1. The first file (data.txt) is the file containing a list of student records.
2. The second file (commands.txt) contains a series of commands, which will tell you
what to compute.
The basic functionality of computing the student list will be implemented using a linked list.
Each node in the list contains student information, and a pointer to the next node.
Hints:
To read the document use the fin>> or scanner method
There are several commands that requires you to check if the list is empty or not.
You need to read from the file "data.txt" to fill the linked list. Then you read from the
"command.txt" file.
Once the list of student records is created, read the commands from the commands file to
compute various operations
Implementation:
For this program you will create the following classes:
⚫ Student.cpp: This class will be used to create objects of type student. Each student
object will store student information (name, ID, GPA).
⚫StudentList.cpp: This class will be used to create a linked list with nodes of type
Student. All the methods will be implemented in this class.
⚫ Project1.cpp: This is the class that will contain main.
Input File Specifications:
You will need to read two text files. This should be automated. Do not ask the user to input
these files.
data.txt: This is the file containing a list of student records.
commands.txt: This file contains the commands that will tell you what to compute.
The Commands to be implemented are as follows:
1. ADDSTUDENT
This command will add a new student to the list. There are 3 parameters for this command (
student name, id, and GPA)
Example Input:
ADDSTUDENT Rana Salah
1000000
4.2
Example Output:
The student record was added successfully
2. STUDENTINFO id
This command will be followed by an integer id. This command will search for a student
with his/her id if the student is found it will print her/his record to the output file. If the
student is not found it will print "There is no record of this student in this system"
Example Input:
STUDENTINFO 1712371
Example Output:
Student name-Raged Alshihri
Student ID-1712371
Student GPA-4.5
3. DELETESTUDENT id
This command will be followed by an integer id. To implement this command, you have to
iterate over the linked list of students you created and delete the student (node). If the student
is not found, the command will print "There is no student with the id "#######" in the
system.".
Example Input:
DELETESTUDENT 1212371
Example Output:
The student record was deleted successfully
4. FINDLARGEST
This command will print the information of the student with the largest GPA.
Example Input:
FINDLARGEST
Example Output:
The student with the largest GPA is:
Student name-Nada Alahmadi
Student ID 1612371
Student GPA 4.7
5.PRINTLIST
This command will print all the student records.
Example Input:
PRINTLIST
Example Output:
The list of students in the system are:
1 - Student name Rana Salah
Student ID 1000000
Student GPA-4.2
2- Student name Reem Ahmad
Student ID 1020000
Student GPA 3.2
3- Student name-Enas Algarni
Student ID 1112371
Student GPA 3.5.
. and so on
6. REVERSEPRINTLIST
This command will print all the student records in this system in reverse order you should
implement this command using recursion.
Example Input:
REVERSEPRINTLIST
Example Output:
11- Student name-Shahad Magrabi
Student ID 1812371
Student GPA=4.0
10 Student name Gumana Algamdi
Student ID 1722371
Student GPA 3.4
9- Student name Raged Alshihri
Student ID=1712371
Student GPA=4.5
Sample Input & Output File:
You must print your output to an output file called output.txt. We have provided you a
sample input with matching output.
***WARNING***
Your program MUST adhere to the EXACT format shown in the sample output file (spacing
capitalization, use of dollar signs, periods, punctuation, etc). The graders will use very large
input files, resulting in very large output files. As such, the graders will use text comparison
programs to compare your output to the correct output. If, for example, you have two spaces
between in the output when there should be only one space, this will show up as an error even
through you may have the program correct. You WILL get points off if this is the case, which
is why this is being explained in detail. Minimum deduction will be 10% of the grade, as the
graders will be forced to go to text editing of your program in order to give you an accurate
grade. Again, your output MUST ADHERE EXACTLY to the sample output.
Grading Details:
Your program will be graded upon the following criteria:
1) Adhering to the implementation specifications listed on this write-up.
2) Your algorithmic design.
3) Correctness.
4) Use of the three classes, as specified. If your program is missing these elements, you will
get a zero. Period.
5) The frequency and utility of the comments in the code, as well as the use of white space
for easy readability. (We're not kidding here. If your code is poorly commented and spaced
and works perfectly, you could earn as low as 80-85% on it.)
7) Your program should include a header comment with the following information: your
name, email, account number, section number, assignment title, and date.
8) Your output MUST adhere to the EXACT output format shown in the sample output file.
Deliverables:
You should submit a zip file with three files inside:
1. Student.cpp
2. StudentList.cpp
3. Projectl.cpp (this is your main program)
NOTE: your name, ID, section number AND EMAIL should be included as comments in all
files!
UML Diagrams:
For this program, you will create two Classes (UML diagram shown below) and a third class
for the main:
Student
- name: String
- Id: int
-gpa: double
-next: Student
constructors and the getters and setters
as needed
Application
main method
and any other methods as you need
StudentList
-head: Student
constructors and the getters and setters
and all other methods you need
Output.txt
Х
--PRINTLIST Command-
Algarni
The list of students in the system are:
1 Student name-Enas
Student ID-1112371
Student GPA=3.5
2 Student name-Lama Omran
Student ID=1212371
Student GPA-2.5
3 Student name-Fatemah Ali
Student ID-1512371
Student GPA-1.5
4 Student name-Waad Alzahrani
Student ID=1611111
Student GPA=4.5
5 Student name-Barah Raheem
Student ID 1612351
Student GPA-2.5
6 Student name-Reham Asiri
Student ID=1612371
Student GPA-1.3
7 Student name-Nada Alahmadi
Student ID=1612371
Student GPA-4.7
8 Student name-Raged Alshihri
Student ID 1712371
Student GPA=4.5
9 Student name-Gumana Algamdi
Student ID=1722371
Student GPA-3.4
10 Student name-Shahad Magrabi
Student ID=1812371
Student GPA=4.0
--ADDSTUDENT Command--
The student record was added successfully
-ADDSTUDENT Command-
The student record was added successfully
Output.txt
The student record was added successfully
PRINTLIST Command---
The list of students in the system are:
1 Student name Rana Salah
Student ID 1000000
Student GPA=4.2
2 Student name Reem Ahmad
Student ID 1020000
Student GPA-3.2
3 Student name-Enas Algarni
Student ID=1112371
Student GPA-3.5
4 Student name-Lama Omran
Student ID-1212371
Student GPA=2.5
5 Student name-Fatemah Ali
Student ID=1512371
Student GPA-1.5
6- Student name=Waad Alzahrani
Student ID-1611111
Student GPA=4.5
7 Student name-Barah Raheem
Student ID 1612351
Student GPA-2.5
8 Student name-Reham Asiri
Student ID=1612371
Student GPA=1.3
9 Student name=Nada Alahmadi
Student ID-1612371
Student GPA-4.7
10 Student name-Raged Alshihri
Student ID=1712371
Student GPA=4.5
11 Student name Gumana Algamdi
Student ID=1722371
Student GPA-3.4
12 Student name-Shahad Magrabi
Student ID=1812371
Student GPA=4.0
Х
Output.txt
-DELETESTUDENT Command-
******
The student record was deleted successfully
-DELETESTUDENT Command---
******
There is no student with the id"1111111"
system.
-----------PRINTLIST Command---
The list of students in the system are:
1 Student name Rana Salah
Student ID 1000000
Student GPA-4.2
2 Student name Reem Ahmad
Student ID=1020000
Student GPA-3.2
3 Student name-Enas Algarni
Student ID 1112371
Student GPA=3.5
4 Student name=Fatemah Ali
Student ID=1512371
Student GPA-1.5
5 Student name-Waad Alzahrani
Student ID=1611111
Student GPA=4.5
6 Student name-Barah Raheem
Student ID-1612351
Student GPA=2.5
7 Student name-Reham Asiri
Student ID-1612371
Student GPA=1.3
8 Student name-Nada Alahmadi
Student ID=1612371
Student GPA-4.7
9 Student name-Raged Alshihri
Student ID=1712371
Student GPA=4.5
10 Student name-Gumana Algamdi
Student ID 1722371
Student GPA=3.4
×
in the
Output.txt
Х
8 Student name-Nada Alahmadi
Student ID=1612371
Student GPA-4.7
9- Student name=Raged Alshihri
Student ID-1712371
Student GPA=4.5
10 Student name Gumana Algamdi
Student ID 1722371
Student GPA-3.4
11 Student name-Shahad Magrabi
Student ID=1812371
Student GPA-4.0
-STUDENTINFO Command-
Student name Raged Alshihri
Student ID-1712371
Student GPA=4.5
--STUDENTINFO Command-
Student name= Reem Ahmad
Student ID-1020000
Student GPA-3.2
--STUDENT INFO Command-
There is no record of this student in this system
-FINDLARGEST Command-
The student with the largest GPA is:
Student name-Nada Alahmadi
Student ID 1612371
Student GPA=4.7
-----------REVERSEPRINTLIST Command--
11 Student name-Shahad Magrabi
Student ID=1812371
Student GPA-4.0
10 Student name=Gumana Algamdi
Student ID-1722371
Student ID=1612371
Student GPA=4.7
************
Output.txt
-----------REVERSEPRINTLIST Command---
****
11 Student name-Shahad Magrabi
Student ID=1812371
Student GPA 4.0
10 Student name=Gumana Algamdi
Student ID=1722371
Student GPA=3.4
9 Student name-Raged Alshihri
Student ID=1712371
Student GPA=4.5
8 Student name-Nada Alahmadi.
Student ID 1612371
Student GPA=4.7
7 Student name-Reham Asiri
Student ID=1612371
Student GPA=1.3
6 Student name-Barah Raheem
Student ID=1612351
Student GPA-2.5
5 Student name-Waad Alzahrani
Student ID 1611111
Student GPA=4.5
4 Student name-Fatemah Ali
Student ID=1512371
Student GPA=1.5
3 Student name-Enas Algarni
Student ID=1112371
Student GPA-3.5
2 Student name Reem Ahmad
Student ID=1020000
Student GPA=3.2
1 Student name Rana Salah
Student ID=1000000
Student GPA-4.2
Goodbye.
***
Х
10
Waad Alzahrani
1611111
4.5
Gumana Algamdi
1722371
3.4
Raged Alshihri
1712371
4.5
Reham Asiri
1612371
1.3
Nada Alahmadi
1612371
4.7
Shahad Magrabi
1812371
4.0
Barah Raheem
1612351
2.5
Fatemah Ali
1512371
1.5
Lama Omran
1212371
2.5
Enas Algarni
1112371
3.5
data.txt
Х
commands.txt
Х
PRINTLIST
ADDSTUDENT Rana Salah
1000000
4.2
ADDSTUDENT Reem Ahmad
1020000
3.2
PRINTLIST
DELETESTUDENT 1212371
DELETESTUDENT 1111111
PRINTLIST
STUDENTINFO 1712371
STUDENTINFO
STUDENTINFO
FINDLARGEST
REVERSEPRINTLIST
QUIT
1020000
0000000
Read_a_File.txt.txt
Х
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main() {
// open a text file
ifstream MyReadFile("filename.txt");
string myText;
if (MyReadFile.is_open())
}
// Use a while loop together with the
getline() function to read the file line by line
while (getline (MyReadFile, myText)) {
}
}else{
// Output the text from the file
cout << myText<<endl;
cout << "Unable to open file";
}
}
// Close the file
MyReadFile.close();
check_circle الجواب — حل مفصل خطوة بخطوة
hourglass_top
🔒
الحل الكامل متاح للمشتركين
اشترك في أرشيف الأسئلة لعرض هذا الحل وآلاف الحلول المفصلة خطوة بخطوة من معلمين معتمدين.