Question: here is the file: please help me with this C ++ problem This assignment will test your ability to write a C program that is









here is the file:
please help me with this C ++ problem
This assignment will test your ability to write a C program that is made up of functions stored in different files. The main topic that this assignment is using proper parameter passing. You will have to decide what parameters should be passed by copy and which should be passed as addresses, properly dereferencing those parameters in your functions. Incorrect parameter passing or a lack of demonstration that you know how to pass parameters properly will result in a low grade. The assignment is to write a program to predict earnings potential for students. The students' information will be stored in a text file. Your program will open the file, use a loop to input each student's information, compute the student's earning potential, output this student's earnings potential, and update some running totals. Upon completion of processing all students, a summary will be output. All input comes from the text file and all output goes to the console (using printf). This program must be broken into the following functions. Additional functions may be used. 1. main - declare all variables needed for main, open the input file, use a while loop to input the next student, call the necessary functions to compute and output the student's earning potential, and update running totals. After the loop ends, close the file and call a function to output a summary. 2. input - receive the FILE * variable along with all of the variables that will store input values. The function should consist of one fscanf instruction. It is recommended that this function be an int function returning the result of fscanf (that is, the body of the function is return fscanf (); ). In main, the while loop's condition would then be while (input (...) !=EOF) \{\} so that the loop iterates while the input function does not return EOF. Each student in the input file is listed on one row and consists, in order, of: first name, last name, major, minor, years of work experience, number of honors courses, number of extracurricular activities, number of volunteer activities and GPA. The first four are strings, the rest are ints except GPA which is a double. values). As the function needs to compute three things, you have to pass these as addresses in the parameter list instead of using a return statement. The computations are shown on page 3 of this assignment. The computations require using the student's major, minor, four int values and gpa. All of these need to be passed to the compute function (but not as addresses since these values will not change). If desired, you can have this function call three additional functions, one each to compute the base salary, potential bonus and potential ceiling. Or, all three values can be computed directly in this function. 4. range - given the base, bonus and ceiling values computed in the compute function, the range function computes the student's expected starting salary and maximum career salary (both are int values). Like compute, since you need to return two values, they must be passed appropriately through the parameter list rather than a return statement. 5. output - output to the console (using printf) this student's first and last name, starting and maximum salaries, in a formatted way. An example of how this might look is given on the last page of this assignment. 6. update - given the total number of students processed so far, the total number of tech majors processed so far, the starting and maximum salaries for this students, the total starting and total maximum salaries of all students processed so far, the total starting and total maximum salaries for tech majors processed so far, and this student's major, update the number of students, the total starting and maximum salaries, and if this student is a tech major, the number of tech majors and the tech major starting and maximum totals. This should be a void function. All parameters that are passed that will change (e.g., number of students) and may change (e.g., number of tech majors) need to be passed as addresses while parameters that will not change (e.g., this student's starting salary) should not be passed as addresses. 7. isTech - a function which receives a string that will be either a student's major or minor and will return true (non-0) if this student's major is one of the tech disciplines, false (0) otherwise. See the list below. 8. isScience - same but for science disciplines. 9. isHumanities - same but for humanities disciplines. 10. summary - given the total number of students, total number of tech majors, total starting salary, total maximum salary, total starting salary for tech majors and total maximum salary for tech majors, compute the average pay for all students: (total starting + total maximum salaries) / (2 total number of students). If there were any tech majors, also compute the average pay for tech majors. Output the number of students, number of tech majors, the average salary, and if there were tech majors, the tech majors' average salary. Assume there will be at least 1 student processed but there may not be any tech majors so the code to compute and output tech major's average salary needs to be done in an if statement to avoid a division by 0 error. Note that the averages should be declared as local variables and will be doubles. If you look at the payroll.c sample program, you will see that iterating through the records of the input file was handled by first inputting the number of employees in the file (the first value of the file is this number) and then using a for-loop to iterate over that many employees. In this assignment, there is no number to indicate the number of students in the file, so you can't use this file is this number) and then using a for-loop to iterate over that many employees. In this assignment, there is no number to indicate the number of students in the file, so you can't use this approach. Instead, use a while loop as noted above in the description for the input function. This approach works because the input function will return the value returned by the fscanf statement. Note that if you use 1 instead of EOF, you should comment what 1 means. Note: you may not have called your input function "input" so your while loop may look different. Tech disciplines are ASE, CIT, CSC, CYS, DFX and DSC. Science disciplines are BIO, CHE, PHY and MAT. Humanities disciplines are ANT, ART, ENG, HIS, MUS, PHI, and SOC. Other majors will not be categorized (such as BUS, BIS). Use strcmp (part of the string.h library) to compare the string parameter to one of these strings, e.g., strcmp(str, "ASE"). strcmp returns an int value which will be a negative number if str "ASE". Here, you will only need to test to see if stremp returns 0 . If so, your function will return a non- 0 value, for instance 1 , and 0 if strcmp does not return 0 . You will need to test the string against all of the disciplines for that particular classification (e.g., BIO/CHE/PHY/MAT for science). Your code can be a single if-else statement where the condition is a series of OR tests as in (strcmp(str,"BIO")==0strcmp(str,"CHE")=0). The formulas to compute the base, bonus and ceiling values are given at the top of the next page. You are to use constants, defined with \#define statements, for those values listed in italics. For instance, the two GPAs used as thresholds (3.25,2.50) for adjusting base salaries are to be defined as constants. Use reasonable names for your constants. Your \#define statements will be placed in your header file (see the description of the header file on page 4). The other values listed on the next page, like 56000 , can be hard-coded as literal numbers into the program instead of being constants. The base salary is 56000 for tech majors 48000 for science majors 36000 for humanity majors 40000 for everyone else Base salaries are adjusted as follows +4500 if a tech minors +2500 if a science minors +4000 if the student has more than 5 years of work experience +3200 if the student has 4-5 years of work experience +2400 if the student has 3 years of work experience +1200 if the student has 1-2 years of work experience +2225 for a GPA >3.25 (this is the high GPA threshold) 1500 for a GPA or else you will receive a warning and your program will not compile. - io.c - this file will start with \#include for your header file and include your input/output functions (input, output, summary). Note that while summary has some computations, we will consider it an output function. - compute.c - this file will start with \#include for your header file and include all of your computation functions (compute, range, update, isTech, isScience and isHumanities, other functions if compute calls separate functions for base, bonus, ceiling). All four files need to be added to your C project to compile and run correctly. One main point of this assignment is to understand proper parameter passing. A parameter passed to a function which will not change in the functions should always be passed by copy. If the parameter is either being input in the function or computed in the function, it needs to be passed as an address (\&). If the parameter may change in the function, again pass it as an address. The exception to this rule is that strings are already addresses, so do not use the \& to pass them. Any address received in the function will appear in the parameter list of the function using the notation type *name as in char *firstName or int *numberofstudents. To access a nonstring in the function, it must be dereferenced using * as in *numberofstudents = numberofstudents +1; Do not use numberofstudents++; to increment a parameter that is an address because this does not work as expected! Do not pass parameters as addresses if not necessary because this is less efficient and you will lose points for doing so. Do not use arrays to pass parameters in an attempt to avoid passing by address and dereferencing. The only arrays permitted in this assignment are strings (first name, last name, major, minor, and the input filename if you choose to input the file's name from the user). Also note that strings, being arrays of characters, need to be declared like char str[10];. Be aware that strings require one extra character to end the string (' 10) and so str above would only be able to store 9 characters. If you think a string needs to store 10 characters, declare it to be at least size 11. The Canvas page containing this assignment also has three text files of input data. Run your program on the first file (p2in1.txt) and compare your output to the output shown at the top of the next page. Once your program is running properly, run it on the other two input files (p2in2.txt, p2in3.txt) and copy that output into your source code in comments. Submit all four files (.c/.h) including the output, as a single Word doc, pdf, text file or .c file. Note: p2in3.txt has no tech majors so you can test the feature of not computing an average salary for tech majors (part of summary) on that file. Sample output for p2in1.txt: FrankZappaMUSARTLaneySchooltreeMUSCITKateBushDSCENGSteveHoweCSCCITRuthUnderwoodASEMUSToddRundgrenMUSHISChristinaBoothCYSHISSteveHackettANTHISGeorgeDukeHISANTAndyLatimerCYSCITAmandaLehmannBUSBIONancyWilsonCITMINGailZappaBUSN/A10PeterHammillPSCASE1226261002628410452205220441253120040143223123.125133120112.17222.8533.66732.9413.42563.5513.0983.6492.7273.8223.4563.8122.433
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
