Need help with this pls!!!!!!!!!!!

A university has polled its students to determine which professors are most popular. The votes cast have been stored in a file. Each line of this file contains a single professor number. In the sample shown below, the first vote cast was for professor 25684, the second vote cast was for professor 14563, and so on.
25684
14563
19677
27684
25678
26890
...
You are to write a program that will read in this file and produce an output file containing a table like that shown below:
Professor Votes
----------------------------
26890 8
27684 5
25678 4
45683 4
15645 3
12356 3
14563 3
25684 3
19677 2
30405 1
Note that the table must be sorted, with the most popular professor in the first position and so on. If two or more professors have the same number of votes (i.e. there is a tie), then the tied professors may be in any order in the output file. For example, in the table above, professor 45683 could be above professor 25678, and the output would still be correct.
Your program should read in the names of the input and output files. If any problems occur in opening these files, you program simply output an error message and terminate.
At most 100 different professor numbers should appear in the input file. If this limit is exceeded, your program should output an error message and terminate.
If the input file contains non-numeric data (e.g. "junk"), your program should report the problem, recover from the error, and keep on reading values. Professor numbers must be 5 digits long, and the first digit cannot be a zero (hint: this means that numbers must be between what and what?). If an invalid number is encountered, your program should report the problem, ignore the invalid number, and continue reading.
You will need two arrays, one to keep track of the different professor numbers that have been seen, and the other to keep track of the number of votes for each professor. These are "parallel arrays". The first element of one is implicitly associated with the first element of the other, and so on. Don’t forget that, when you sort the vote array, every change made must also be applied to the professor number array as well.
Prof Numbers Number of Votes
12467
45634
23412
43563
12798
12365
1


2


1
3


2


1

A sample input file is provided. Note, however, that you should create many more test input files to make sure that your code works properly in all circumstances!
what have you got so far?
I would make a vector so that I can add profs.

Read in every line,

--> already added prof (yes:votes_for_that_prof++; no: addprof,votes_for_that_prof=1)

Sortalgorithm (google it, there are hundreds published in the web)
Last edited on
Topic archived. No new replies allowed.