C++ help

I don't know where to begin with this program.

General Information
This application sort occupations by salary and prints a sorted table. It also calculates average and median salaries.

Detailed Information
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:
Dentist 110890.0
Drafter 32232.0
Programmer 47120.0
Paralegal 32678.0
Nurse 35920.0

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:

Job Title Wage
Dentist $110890.00
Programmer $ 47120.00
Nurse $ 35920.00
Paralegal $ 32678.00
Drafter $ 32232.00

Average wage: $51768.00
Median wage: $35920.00

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.
I don't know where to begin with this program.

Break it into tiny pieces. Let's look for the first piece.

The application asks the user for an input file name.

Do that.
Okay and that file is called occupations.out, but idk what goes in there
Okay and that file is called occupations.out

That's incorrect. Read the assignment again more carefully.
Last edited on
No I know that, its

cout << "Please enter filename?";
cin >> filename;
Don't they teach program flow charting in school anymore ?
What is that? Never heard of that

It is? Okay then I don't know. Its confusing to me
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.
Topic archived. No new replies allowed.