How would you go about writing this program?

I am taking an advanced programming class this summer and I am struggling with it. I have an assignment due tomorrow and I need to figure out how to go about writing this program. Any ideas?

It is a review of file handling with an undetermined number of records, parallel arrays, and functions.

------------------------------------------------------------------------------
The Athletic Club wants you to write a program to determine its weekly payroll.
The company has supplied you with a file containing the name, company ID for each employee, the department where each employee works, the hours each employee has worked, and the rate of pay each employee makes. You should create your own data file for testing purposes. You can name the file anything you would like because your program should ask the user for the name of the file where the real employee data is stored.

Remember you do not actually have any idea what data is really stored in the file. All you have been told is that each employee's name will not exceed 18 characters, their company ID numbers are 4 digit integers, and their department is either A B or C.


Program requirements:

1. Write the main function so that it does little more than call other functions. Main function will consist of the functions:
NameTheFile
OpenTheFile
GetTheData
CalculateTheTotalPay
PrintTheData
(Name the executable file Lab1part2)

2. Ask the user for the name of the data file. In a separate function

3. All opening of files, reading from files, writing to screen or files should be performed in separate functions. Do not forget to verify that the input file opened successfully.

4. Read in all of the data until you reach the end of the file. Use the eof member function to determine where the end of the file is.

5. Input/load five of the arrays. The first array should hold the employee names, second should hold the company ID's, third should hold departments, fourth should hold number of hours worked, and fifth should hold each employee's rate of pay.

After the data has been read in and stored in the arrays, compute and store in ANOTHER parallel array the total pay owed each employee. Anything over 40 should be paid at 1.5 * the rate of pay.

NOW print out all of the information stored in each of the six arrays in nice column format of your choice with proper headings over each column. Make sure all the decimals line up.

-------------------------------------------------------------------------------

There is a part 2 but I won't get into that right now. This may seem easy or self explanatory to you but getting started is the hardest part for me.


Thank you.
Last edited on
closed account (jvqpDjzh)
Nobody here does homework for the others, from what I know. I suggest you to first try to do something by your own and then, if you can't solve a particular problem, post your question ;)
I am NOT asking anyone to do my homework for me. I am asking for help or advice on how to get started.

Why are people so unfriendly here?
They aren't being unfriendly, the problem is that you basically have presented nothing. All you've really said is "I have no idea how to go about doing this", and then copy-pasted the assignment text. It usually helps to start with something (actual code) that you can then ask questions on.
Last edited on
People are not unfriendly here they simply expect you to put in some effort and show where you are having trouble. If it is getting started, start with the first requirement:
1. Write the main function so that it does little more than call other functions.

Then go to the next requirement:
2. Ask the user for the name of the data file. In a separate function

If you cannot get at least that far, you probably shouldn't be taking an advanced course since it doesn't get much more basic than that.
How would you go about writing this program?


I think I'd first figure out my sample data file, since I'll need to read that in to be able before moving through the rest of the program. The assignment already breaks out steps into separate functions, so I'd start pseudocoding out the steps I need in each function and deciding what information I need to send in and return (if any) with the function.
The assignment is very specific and pretty much tells you what to do, how to divide the program into functions, etc. Read the assignment carefully a couple of times and then start writing the functions that it asks for.

You can do this.
You say that this is a "review" on some concepts. Reviews should follow introduction, so you should have had those concepts on the course already and judging by their nature you should have seen a program or two already. Read through that material that you already have.
Do I create my own sample data and store that in a file to use in the program? Or am I asking the user to input this data?
Last edited on
It says the company is giving you a file and that you should create your own data file for testing purposes. You'll be asking the user to give you the name of the file - not the data in it.
2. Ask the user for the name of the data file.

The program will ask for a name of a file. When you test it, you are the user, so you must have a sample data file of your own.
I'm sorry this part doesn't make sense to me. Maybe it's the wording of it. I know it's a hypothetical situation but I didn't actually receive any information or file from the company with the employee name, ID, department, hours worked, or rate of pay.

So do I simply make up this information in my own data file?

I know this is frustrating but I genuinely do not understand what to do for this part and I can't really move on until I get it straight.
So do I simply make up this information in my own data file?

Yes.
Remember you do not actually have any idea what data is really stored in the file. All you have been told is that each employee's name will not exceed 18 characters, their company IS numbers are 4 digit integers, and their department is either A B or C.


I'd follow this guidance to create the file, i.e. the name can be up to 18 characters, department number is 4 integers, department code is one letter character.

And it will also include this information for each employee.
the hours each employee has worked, and the rate of pay each employee makes.

So do I simply make up this information in my own data file?

Yes.


Okay, thanks.

And thank you to everyone that replied. I appreciate your help. I feel comfortable enough to finally begin working on my program now. I just needed to make sure I understood the program and requirements first.
Note you must press the Enter key after each name and after each Rate of Pay when you key in this file. That means, for every row in the above table, you will have to enter two lines in the input file for each employee. The first two lines should look like:

SAMPLE:
Betty Black
1025 A 42.00 9.50

You must also use the PICO, VI, or some other editor to key it in or your c++ program may not be able to read it correctly."


I'm using Codeblocks to write this program. How do I "key in" this sample information for the data file using Codeblocks? Should I be using Codeblocks?

He's just saying to use a text editor as opposed to something like notepad so the file is read properly. You should be able to create a text file in CB.
Topic archived. No new replies allowed.