Computer Science
CSE 1320- INTERMEDIATE PROGRAMMING
Lab 4
Due: Nov 7th, 2020 11:59 PM
The Lab 4 submission guideline:
(1) Please create a .c file for your program.
(2) Please prepare a text (.txt) file, clearly describing how to run your program and what input to
give. Your file should be named Readme.txt.
(3) Zip all the files and Submit your Lab 4 through Canvas. URL for the Canvas is
https://uta.instructure.com/
(4) Note that program should be tested on Omega using gcc before submission.
Make sure you follow the good programming styles, for example, comments, indentation and white
space.
Instruction: You must use pointers for this lab. No arrays, no structures. For example, if you
need an array of floats to hold the scores, do not use float score[15]. Rather use float *score,
then use dynamic memory allocation to hold required memory. You must use memory
optimally, that is if you have only 6 scores, you must point to a memory chunk of sizeof(float)*6
bytes.
Similarly, to hold a name, instead of doing it with 2D char arrays, use 2D pointers (char
firstName[15][20] → char **firstName).
Problem:
Write a menu based program to maintain student records. Your program should take the following
inputs:
1. Student first name (max. 20 characters)
2. Student last name, (max. 20 characters)
3. Student scores (float/double), e.g. 85.4
Your program should be able to take records of a minimum of 5 students. After taking the records,
you should provide 8 functionalities to the user.
1. Print records – prints records of all students
2. Add a new record – take a new record from the user for a new student. Be careful, you may
needto allocate more memory using dynamic memory allocation.
3. Delete record(s) – to delete a record, ask for the last name of the student from the user. If thereare
multiple students with same last name, you must delete all of their records. You must free up the
memory holding these records.
4. Search by last name – prints record of the student with a given last name. If there are
multiplestudents with the same last name, print records for all of them.
5. Sort by score – sort the records of students according to their scores, and then print the
sortedrecords.
6. Sort by last name – sort the records of students according to their names alphabetically, and
thenprint the sorted records.
7. Find the median score – compute the median score and print it. Also, print how many students are
above this median score.
8. Exit the program – terminate on a specific input from the user. Let that specific input be aninteger
of value 0.
You should print the record in the following format:
First Name: firstname 1, Last Name: lastname 1, Score: score 1 First
Name: firstname 2, Last Name: lastname 2, Score: score 2
.
. .
You should write each functionality from 1-7 in separate functions. You should provide a menu to
the user as following: For inputs:
Please indicate number of records you want to enter (min 5, max 15): #of records After user
gives the number of records, you should inform the user how to enter the records: Please
input records of students (enter a new line after each record), with following format first
name last name score After user gives the inputs for the records, inform the user about the
functionalities: Print records (press 1)
Add a new record (press 2)
Delete record(s) (press 3)
Search by last name (press 4)
Sort by score (press 5)
Sort by last name (press 6)
Find median score (press 7)
Exit the program (press 0)
After user chooses functionality, your program performs that and provides this menu again to select
another functionality. This goes on until user presses 0.