Calculate the course average across all students for an


Assignment Details

Carefully follow the directions below to prepare the necessary solution files. When you have completed the assignment, submit the following files through the course Moodle:

- courseBuddy.cc - all source code for your program
- README.txt - external documentation for your program (see instructions in section 3.5)

Remember to put your name, student number and NSID at the beginning of any files you are submitting. For any C++ code files, include this information using code comments.

1.1 Special Directions

Your solution to this assignment should be developed on tuxworld using the bash shell. Your submission will be marked in this environment.

2 Introduction

For this assignment, you will be developing a more comprehensive version of the "Course Buddy" program introduced in assignment 1. In particular, we want to build a program which keeps track of all the students in a course and the grades they have achieved based on the program requirements below. You will use procedural C++ to write this program, meaning your program will closely resemble programming in C.

Programming in Procedural C++
Note the following specific notes and restrictions on using "procedural C++":

- Unlike C++, C does not have a real Boolean type and does not allow you to declare variables in your programs except at the beginning of functions. You are permitted to use the bool type and to declare variables anywhere you need in your file as C++ permits.

- Unless otherwise specified, you are not permitted to use any of the object-oriented features of C++. This includes using cin, cout and cerr to read and write to the console. Instead, make use of the printf(3) and scanf(3) families of functions from the C stdio.h library.

- You may use either the C or C++ methods for requesting memory dynamically. Choose one method and stick with it for your entire program. I suggest beginners use the C++ keywords new and delete to create and destroy dynamic memory, however students looking for a challenge may wish to use the C standard library functions malloc() and free().

We are essentially writing C programs, but compiling them using the C++ compiler. This choice was made to simplify some of the challenges of working in C which can make it difficult for beginners to write code with good style. If you would like any clarification as to whether a C++ feature is available or not for this assignment, ask on the forums or consult with the instructor.

Description of Course Buddy

Course Buddy will be the focus of this assignment and the next assignment. The work you do on this assignment will carry through to the next assignment. Below is a description of the features this program will have by the end of the next assignment, but not necessarily by the end of this assignment.

Course Buddy is a program which keeps track of all the students in a course and the grades they have achieved. It is helpful to outline some assumptions made about the types of courses it can represent:

- All information is stored in a "volatile" format meaning that all information is lost when the program terminates. This implies that every time the program is launched the user starts with an empty database.

- The following data is tracked for each student: student ID, name, assignment grades, exam grade and final course grade.

- Each student is uniquely identified by their student ID, which allows two students to have the same name. Student IDs start at 0 and increment by 1 as new students are added. Students are added dynamically by the user.

- An arbitrary number of assignment grades can be tracked for each student provided that all students were assigned the same number of assignments. The number of assignments is hard-coded in the source code, not determined by the user.

- Each assignment is uniquely identified by its assignment ID ranging from 0 to the number of assignments minus 1.

- Only one exam grade is tracked for each student.

- A student's final grade can be calculated by the following weighted sum: 50% exam and 50% assign- ments, where each assignment is worth an equal amount.

- Assignment and exam grades are entered as whole number percentages. The final course grade and calculated averages may be floating-point values.

- There is a fixed maximum number of students which can be added to the system over the course of the program's runtime, also hard-coded in the source code.

A user can perform the following actions using Course Buddy:

- Add and remove individual students
- Print out all information for a specific student
- Print out all information for all students
- Update the assignment and exam grades for a specific student
- Calculate the student's final grade based on the assignment and exam grades
- Calculate the course average across all students for an individual assignment, the exam or the final course grade
- Import student data from a file (next assignment)

For this assignment, you will not worry about building an intuitive user interface for Course Buddy. The user interface will come later in the next assignment. Your focus will be on the process of developing the necessary functions incrementally and writing tests for those functions.

3 Assignment Requirements
This section contains specific details outlining how your program should implement the program described in section 2.

Data Types
You will need to define an appropriate data structure named student to contain data for each student. Within your structure, carefully select the most appropriate data type for each component (student ID, name, assignment grades, exam grade and final course grade) based on the program description above.

You will also need to define global variables and constants as appropriate. For example, you may want to create a global array containing a list of pointers to all the students in your database.

Functions
You must define the following functions based on the provided function headers. Preserve the given function names, parameter types and return types to make marking easier.

student* allocateStudent(char* name) - dynamically allocate space to store one student with the given
name and initialize all its values sensibly

bool deallocateStudent(int id) - delete the given student and free up any allocated space that student's record was using

bool gradeAssignment(int student_id, int assignment_id, int grade) - adjust the grade for the given assignment for the given student

bool gradeExam(int student_id, int grade) - adjust the given student's exam grade

bool calculateFinal(int id) - calculate the given student's final grade

float getAssignmentAverage(int assignment_id) - calculate the course average for the given assignment

float getExamAverage() - calculate the course average for the exam

float getFinalAverage() - calculate the course average for the final course grade

void printStudent(int id) - print all information about one student

void printAllStudents() - print all information for all students

Note: most functions should have a designated return value if an error occurs. Functions returning bool
types should return false, functions returning memory pointers should return NULL, etc.

Coding Process
The purpose of this assignment is to give you an opportunity to practice the software development techniques introduced in the lectures. For our purposes, it is more important to show evidence that you understood the techniques seen in the lectures than it is to produce a practical software product. You are to develop Course Buddy following the principles of Test-Driven Development (TDD) outlined and demonstrated in the lectures.

TDD is summarized by the flowchart on slide 26 of lecture topic 10. For each function above, you should start by writing a stub function which consists of the function header and a return statement which initially returns an arbitrary value. Next, write a unit test for that function within your main() function which tests functionality that has yet to be implemented. This test should initially fail. Now write just enough production code for your function to pass the test. Alternate between writing unit tests and writing just enough code for the test to pass until all necessary functionality is present.

When writing your unit tests, keep the principles of testing introduced in lecture topic 9 in mind: boundary conditions, defensive programming, white box vs. black box testing and maximizing test coverage. Keep your tests simple, varied and thorough. Remember that unit tests should be silent unless they encounter errors. Use assertions in your unit testing where appropriate.

When writing your functions, remember to check the pre- and post-conditions. If you encounter an error, carefully choose the least disruptive way to inform the user. For example, if your function receives a value which is out of range and the error is not critical for your program to run, consider returning an "error" value rather than using an assertion.

Surround your unit tests in your main() function with #ifdef TESTING and #endif // TESTING which will allow you to compile your program with or without your unit tests.

Remember the principles of good programming style (lecture topic 5) and defensive programming (lecture topic 8) as you implement Course Buddy. Some important considerations for when your work is evaluated:

- Keep all lines of code shorter than 100 characters long.
- Choose appropriate variable and function names.
- Use a consistent indentation style.
- Comment your code when appropriate. Follow the programming guidelines for templates discussed in lecture topic 10.

Compilation and Execution
Your program must compile without errors or warnings using the following commands to the compiler:

- g++ -Wall -Wextra -o courseBuddy courseBuddy.cc
- g++ -Wall -Wextra -DTESTING -o courseBuddy.testing courseBuddy.cc

When executing your regular courseBuddy program, there should be no output and your program should terminate successfully. When executing your courseBuddy.testing program which contains your unit tests, each unit test should be executed and the program should terminate successfully only if no errors were identified.

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: Calculate the course average across all students for an
Reference No:- TGS02322791

Expected delivery within 24 Hours