Question: Create a program in C(Just C) that reads in a file specified with a command-line argument . The program will continually rank each student based
Create a program in C(Just C) that reads in a file specified with a command-line argument. The program will continually rank each student based on their number of votes. The user will vote for a student based on their rank. Initially each student has zero votes and rank is set randomly. (Rank order does not matter if the number of votes are the same).
Use a sorting method to sort the names based on the number of votes. Update the rank every time there is a vote. Comment your code appropriately. You can assume only integers will be entered as input, however you must check that the digit is in the appropriate range.
Example output: Vote for? (0 to quit) 1 Rank:1 Votes: 9 Jacobs, Mark. Rank:2 Votes: 8 Hendervile, Jason W. Rank:3 Votes: 7 Simmons, Jack J.
Update:
The number of students in the file is 54. It is fixed. With each vote, the student's ranking should be sorted and the list re-displayed with new rankings. The file is in .txt format.
Update 2:
The code file is vote.c , the data file is student.txt.
Update 3:
First can you please specify how the data in the file is present. Secondly do we need to update the file every time the order changes or just to show in the program?
The data is in a text file in the following format: "StudentLastName, StudentFirstName MiddleInitial." Every student lastname, name is on a separate line. The file does not need to be updated or changed in any way. The file must be called from the command line however, for example " $./a.out students.txt". Changed rankings should just be displayed in the program after every vote. Important: Please use insertion sort to change rankings based on entered vote. Voting is done by entering the rank number of the student, then 1 vote gets automatically added to that student. The beginning ranks should be random, or in any order.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
