This application sort occupations by salary and prints a sorted table. It also calculates average and median salaries.
The application asks the user for an input file name. It always writes its output to a file called occupations.out. On each line of the input file there is an occupation job title (without blank spaces with at most 30 characters) followed by a floating-point number representing the national average salary. Your program should be able to process 20 occupations (so, your arrays will have 20 elements). The contents of a sample input file:
The program reads in the data from the input file into two parallel arrays - One either an array of type string or a 2D array of characters for the occupation job titles and a 1D array for the wages. The program sorts the data by wage values from highest to lowest. It prints a table of the sorted data to the output file formatted as shown below. You can assume that no occupation job titles will be more than 30 characters and occupation job titles will not have blank spaces in them in the input file. All wage values will be less than 1 million. The program calculates and prints the average and median wage values. Format wages with a $ and exactly two digits to the right of the decimal. Job titles should be aligned to the left, wage values to the right. Example output file:
If the input file entered by the user doesn’t exist, print the following error message to standard output with the entered input file name in it instead of the table and end the program.
Input file _________ does not exist.
If the input file has more than 20 occupations in it, do not process the ones after 20.
It gives you sample files. Just think of 20 jobs and give them arbitrary salaries. Start with that. Once you have a file of 20 jobs with salaries, write some code that will read these jobs into an array, and read the salaries into another parallel array.
Then sort these arrays by wage, from highest to lowest. Use whichever sort algorithm you're comfortable with (I can guess this will be the spot to give you issues).
After this, output the information into a second file.