This is an office hour simulation. Students will arrive at a random time and will meet with the professor for a random amount of time. Student names and subjects are generated from "Subjects.txt" and "Student Roster.txt" respectively. By default, the program runs 100 simulations.
Feel free to add subjects to "Subjects.txt" and names to "Student Roster.txt". Plus, feel free to change the "numberOfSimulations" (line 26 of main.cpp), how often students arrive (lines 105 and 133), or how long students meet with the professor (line 114). You can set the program to 10,000 simulations if you would like. Just make sure that you have enough memory for it; haha (it'll make over 20,000 files).
I used the C++ STL Queue to keep track of arriving students, the C++ STL Priority_Queue to keep track of students that are currently in line to meet with the professor, and the C++ STL Multimap to record and generate reports on what each student attended office hours for. I used the C++ Vector to store all the data for sorting and searching. I used my own implementation of insertion sort to generate the sorted report and I used my own implementation of serial search to search through all the subjects and names.
To compile the code, open terminal/command prompt to this directory and send the following command: "g++ -std=c++11 main.cpp student.cpp -o main". This will make an executable file called main.
After the code has compiled, you can execute the executable file that was just created by sending the following command: "./main".
This should run the program.
Sample Output
> ./main
The average office hour
has 11.730000 students
is 75.630000 minutes long.
runs 15.780000 minutes overtime.
has the professor waiting for 10.610000 minutes.
has each student waiting for 9.520034 minutes.
has 5.543052 minute long meetings.
The average student
has visited office hours 33.514286 times.
has waited for 319.057143 total minutes.
has met with the professor for 185.771429 total minutes.
For the sorted report, please enter whether you would like to sort by name or subject [N/S]: N
Would you like to search for a specific student or subject (y/n)?
y
Please enter whether you are searching for a name or a subject [N/S]: S
Please enter the name of the subject you are searching for: Kyle
Here are the students that have asked questions regarding Kyle.
Sorry! Nothing found for Kyle. Please make sure that you did not make any typos.
Would you like to search for a specific student or subject (y/n)?
y
Please enter whether you are searching for a name or a subject [N/S]: N
Please enter the name of the student you are searching for: Kyle
Here are the subjects for which Kyle has come to office hours for.
Calculus 1
Calculus 1
Calculus 1
Calculus 2
Calculus 2
Calculus 2
Calculus 2
Calculus 2
Calculus 3
Calculus 3
Calculus 3
Calculus 4
Calculus 4
Data Structures
Data Structures
Data Structures
Data Structures
Discrete Math
Discrete Math
Discrete Math
Introduction to Computer Science
Introduction to Computer Science
Introduction to Computer Science
Introduction to Computer Science
Introduction to Computer Science
Introduction to Computer Science
Introduction to Embedded Systems
Introduction to Embedded Systems
Introduction to Embedded Systems
Introduction to Logic Design
Introduction to Logic Design
Introduction to Logic Design
Linear Algebra
Linear Algebra
Linear Algebra
Linear Algebra
Operating Systems
Operating Systems
Theory of Algorithms
Theory of Automata and Languages
Theory of Automata and Languages
Theory of Automata and Languages
Theory of Automata and Languages
Theory of Automata and Languages
Would you like to search for a specific student or subject (y/n)?
y
Please enter whether you are searching for a name or a subject [N/S]: S
Please enter the name of the subject you are searching for: Data Structures
Here are the students that have asked questions regarding Data Structures.
Aditya
Andrea
Andrea
Andrea
Arjun
Arjun
Arjun
Arjun
Chiwei
Chiwei
Emma
Emma
Ezra
Ezra
Francesca
Francesca
Francesca
Frank
Frank
George
George
Grace
Grant
Grant
Henry
Henry
Ian
Ian
Jacob
Jacob
Jessica
Jessica
John
John
John
Jonathan
Jonathan
Juan
Juan
Justin
Justin
Justin
Kristi
Kristi
Kyle
Kyle
Kyle
Kyle
Martin
Martin
Pratham
Pratham
Primrose
Primrose
Primrose
Primrose
Samuel
Sarah
Sarah
Sergio
Sergio
Sunjit
Would you like to search for a specific student or subject (y/n)?
n
Thank you for running the Office Hour Visit Simulation!
In addition, the arrival logs, meeting logs, and student reports folders will contain the corresponding data.
The arrival logs will contain "numberOfSimulations" number of files, each containing arrival information for that specific simulation.
The meeting logs will contain "numberOfSimulations" number of files, each containing meeting information for that specific simulation.
The student reports will contain as many files as there are lines in "Student Roster.txt", each containing the subjects for which the student has asked about.
In the end, an overarching sorted report is generated. The user can specify which field to sort by.