Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Introduction This assignment reviews what you learned in BIT 1400. Your job (with some hints along the way) is to create a university registrar that
Introduction This assignment reviews what you learned in BIT 1400. Your job (with some hints along the way) is to create a "university registrar" that has all information about students and courses being offered. Obviously, this is a toy example and this could be any pairing of things like Netflix users and recommended movies or games and game systems. Registrar Our "registrar" is a struct that has 4 elements in it: a dynamic array of student structs, the number of those students, a static or dynamic array of course structs, and the number of courses. Student The student struct contains 3 elements: the student's name (this can be a constant char pointer like const char* name = "Mehdi"), an int student ID, and a pointer to the course the student is taking.....notice you normally take multiple classes but that just makes the problem more difficult. Here would be one possible definition of a student struct in case this helps you: Here is a dataset to use (feel free to modify to use with your struct definitions): a1_studentln students[6] = \{\{"Mehdi Niknam", 12345, "BIT2400"\}, \{"Joe Smith", 54321, "BIT2400"\}, \{"Brian Brown", 11111, "BIT1400"\}, \{"Raymond Rose", 55555, "BIT1400"\}, \{"Gene Eric Student", 99999, "ITEC2100"\}, \{"Amanda Spring", 88888, "BIT2000"\}\}; I had to do something sneaky here. I made yet ANOTHER struct (of type a1_studentIn) and named the array of a1_studentIn structs students. Here is the definition of a1_studentIn: array of a1_studentIn structs students. Here is the definition of a1_studentIn: struct a1_studentln \{ const char* name; unsigned int id; const char* courseName; \}; You will then make an a1_student struct with a pointer to the appropriate course matching that name (the instructions are in part 1). Course A course struct has 3 elements: a const char string name, a float class average, and a positive int maximum enrollment. Here is a set of courses you can try: \[ \begin{array}{c} \text { a1_course courses }[4]=\{\{" B I T 2400 ", 71.0,90\}, \\ \{\text { 'BIT1400", 52.7,140\}, } \\ \{\text { 'ITEC2100", 85.3, 15\}, } \\ \{\text { 'BIT2000", 85.3, 15\} \}; } \end{array} \] This is an array of 4 a1_course structs and the array is named courses (very original names I know). This assignment consists of two parts: 1. The midway submission of part 1 is not graded but given to encourage you to work ahead of the deadline (if you claim the assignment took too long, I will check if you submitted this). 2. The final submission .cpp file including part 2. Part 1: Setup 1. Create a new empty project in Visual Studio (NOT a Hello World console example). 2. Make a new .cpp file named A1__CReview_S22.cpp - The should be the last 4 numbers of your Carleton ID....this should keep your ID safe yet makes cheating harder. - Create a new main method. Make sure your code compiles even if it does nothing. Coding 3. Define three structs outside the main function: a1_student, a1_studentIn, and a1_course based on the instructions above....you can change the struct names but I am calling them that. 4. Add the above datasets (or something similar) to your main function. 5. Your a1_student array (the one with pointers) should be a dynamic array and based on the a1_studentIn dataset. You must use malloc or calloc to do this. You can't use new and it can't be a static array without losing some points. 6. Make sure your a1_student array is freed at the end of the main function. - You will also need a bit if statement to put most of the code in, just in case the call to malloc/calloc returns NULL. 7. Write a function findCourse that takes an a1_course array, the size of that array and the c-string course name as parameters. The function returns a pointer to the course matching the name or NULL if that string doesn't match a course in the array. 8. Use findCourse to make sure your a1_student array has the correct pointers set up. 9. You may want to write a function printStudents that takes an a1_student array and the size of the array as parameters and returns nothing (void). The function itself calls printf statements to output the useful information about the students. 10. Write your name at the top of the file. 11. Make sure you write your code a little bit at a time and test it before moving on.....you can use printStudents to help you test your code for example. art 2: Registrar 12. Create the registrar struct as described above. 13. | created a function named printCourselnfo which took an a1_course and two cstrings (two const char* named pretext and postText) as parameters. The function then prints out all relevant information about a course in an easy-to-read format. - I did this because I kept having to output course information both for students and for the courses themselves. It was much easier this way. 14. Write a function named numRegisteredStudents that takes an array of a1_students, the number of students and a pointer to a particular a1_course as parameters. The function will return an unsigned int representing the number of students taking that class. For example - unsigned int num1400Students = numRegisteredStudents(students, 6, \&courses[1]) results in num1400Students being 2 (there are 2 students taking course 1: \{"BIT1400", 52.7,140} 15. Write a function named printRegistrar that takes a registrar struct and prints information about all students and all courses. - Requirement: Your printRegistrar function must output all information about each student and each course. In addition, the COMPLETE course information associated with each student must be printed out. See the sample output below for an example. 16. OK. Now to prove your student struct has a pointer in it. In your main method do the following: - Make sure your stucts are set up correctly. - Call printRegistrar to confirm your data looks correct. - Modify one of your courses to increase the enrollment maximum. - Call printRegistrar again. See that the numbers have changed for the student WITHOUT changing any of the student structs
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started