This assignment covers the following topics:
A research grant awarded to three professors: Drs X, Y and Z, are used to fund total of 5 projects. The projects are numbered 1 through 5.
A group of 10 graduate students are assigned to work on these projects. Students could be part of one or more of these projects simultaneously.
The bookkeeping process of these projects requires having access to information on who is on what project under whose leadership, or what are the team members of a certain professor, etc. You are asked to write a program to facilitate such inquires.
A file called ProjectLeaders.txt contains the names of the professors along with the project/s they are involved in. The content of this file could be as follows:
X 1 2 3 5
Y 1 4 5
Z 2 3 5
Please note that we do not know what projects each faculty is involved in, but we know that the first line contains the list of projects for Dr. X, the second for Dr. Y and the third for Dr. Z. For simplicity we go by a single character last names for these faculty.
Hint: you need to find a way to know how many projects to read per line, think of somehow capturing the newline character as a sentinel. See if you can make this work.
An input file called ProjectRegistry.txt contains the list of 10 students' last names along with the projects to which they are assigned . Examples could be:
Carter 1 2 4
Nelson 2 3 4 5
Shaw 1 4
Williams 3 4
Adkins 1 2
Phillips 4
Garcia 1 2 3 4 5
. . .
Note that the same reading strategy works here, we do not know how many projects are listed per student.
Your program should be able to process the following:
Inquiry about a student: This option requires a followup question about the last name of the student, in order to list the projects the student is working on.
You should also be able to answer: Is there a student who works on ALL projects? Or is there a student who works ONLY with a SINGLE professor?
Inquiry about a professor: After answering the followup question about the name of the faculty, your program should be able to list of their team members based on the project/s they lead. An example for Dr. Y based on the example file given above could be:
Project 1: Carter Shaw Adkins Garcia
Project 4: Carter Nelson Shaw Williams Phillips
Project 5: Nelson Garcia
You should also be able to list their faculty collaborators on projects: Again an example for Dr. Y:
Project #1: Dr. X
Project #5: Dr. X Dr. Z
Inquiry about a project: after prompting the user for a number in 1-5, your program should be able to list the name/s of the students working on the project as well as the name/s of the faculty working on the project.
The common theme of requirements of this assignment is a "systematic collection of data based on multiple criteria". We have seen the use of parallel arrays that has made such scenarios possible. Another useful trick that we must use here is the concept of "tally arrays". This is where we use the indices of an array with as much importance as the contents they represent.
Let's take a look at example lines of data in our ProjectRegistry file:
Carter 1 2 4
Nelson 2 3 4 5
If we read the last names of the students on each line in a 1d array of strings, we will have a list of projects that are conveniently numbered in the range 1-5 inclusive per line. We know we have exactly 10 lines of data corresponding to 10 students in the file. This should give us an idea of a 2d array of either boolean values or simply integers (0 or 1) to map each student to the project they are part of. The following could give a useful visual of this plan: Note that numbers in bold represent the indices:
0 | 1 | 2 | 3 | 4 | 5 | ||
Carter | 0 | 0 | 1 | 1 | 0 | 1 | 0 |
Nelson | 1 | 0 | 0 | 1 | 1 | 1 | 1 |
... |
This plan requires reading this file into two parallel arrays one is the 1d array that stores last names, and second is the 2d array that uses the project number "as an index" and stores 1 in that element to indicate that the student is part of that project. So when we read 1 for Carter we set the 2d array's [0][1] to 1. The row number 0 represents the index for Carter, and column number1 represents the project 1. When we store 1 in that cell, we are practically marking Carters connection to project #1. The index number maps the project number.
After you have these arrays populated, think of this question: Would you be able to very quickly count the number of students that are part of project #3?
Would it not be as simple as counting the number of ones in column #3?
This is the benefit of "tally arrays".
You can come up with a similar plan about the faculty and projects. But you have to come up with your own "conventions" to map for instance Dr. X to 0 and Dr. Y to 1, etc.
I let you work this out on your own.
So here is what you MUST do in the program:
You MUST USE TALLY ARRAYS
You MUST use FUNCTIONS where you see fit. I let you decide what functions to use forthis assignment. Make sure to use functions that do substantial tasks, receive arrays etc.
The following is the menu that you MUST have in your program. In case there needs to be followup questions as well as additional submenus, they are further indented to emphasize their order of appearance.
The first two lines let the user know the names of the input files this program is processing. Think of a "non-literal way" to incorporate these information in your program. How about prompting the user for two input file names first, before attempting to read from them?
Processing two input files: ProjectLeaders.txt and ProjectRegistry.txt
Please choose a menu option:
1. Inquiry about a student’s list of projects
Please enter their last name:
2. List the name of at least one student who works on ALL projects.
3. (BONUS)List the name of at least one student who works with Only One faculty.
4. Inquiry about a professor, please choose from the following list:
1. Dr. X
2. Dr. Y
3. Dr. Z
1. List the projects and the names of the students working on them.
2. (BONUS)List the projects and the names of the faculty collaborating with them
5. Inquiry about a project:
Please enter a number in the range 1-5 inclusive.
1. List the names of the students working on this project.
2. List the names of the faculty working on this project.
6. Exit