I dont even know where to begin on these

(its an online teach yourself to code site)

they do not give any examples or anything- they went straight from the basic concepts to this...

Write a program that calculates Net Pay. It should do this by calling a function called CalNetPay that calculates and returns Net Pay when given the hours worked and the hourly pay rate.
Arguments must be passed to CalNetPay By Value. CalNetPay MUST RETURN Net Pay, it must use a return statement.
The main function should pass the hours worked and pay rate to the function CalNetPay. The main function should get the hours worked and pay rates from a file called Lab6A3Input.txt that you will create. From the main function: 1) Print to the Screen; 2) Print to an output file called Lab6A3Output.txt, the Net Pay for each record in the Input file.
• Lab6A3Input should contain the following lines:
2 10.5
5 20
10 30.2
• Your program should open the Input file and make sure the open was successful.
• Your program should use a while Loop to process and read the data from the Input file. The while loop should continue execution as long as values are read from the file.
• Don’t forget to close your input and output files when done.

Write a program that prompts a user for their grades, finds the average and prints out a letter grade.
• From main, the program calls a function called GetGrades that will prompt the user for the number of grades they
want to input, and read in those grades from the keyboard. GetGrades will find the sum of those grades and pass the
sum and number of grades to another function called FindAverage.
• FindAverage will find the average of the grades and return this average to GetGrades.
• GetGrades will return this average to main.
• The main function will then determine the letter grade that corresponds to the average and print out the average
and letter grade.
• 90–100 A
• 80–89 B
• 70–79 C
• 60–69 D
• 0–59 F
Note: All arguments in this Lab must be passed by Value. GetGrades and FindAverage functions must return their
result to the calling function.
Output Runs:
Run1 – 30, 50, 90, 100.
Run2 – 85, 89, 90, 95, 78, 99.
Run3 – 85, 95.
 
Well, what is your concrete question? What have you tried so far?

You can't just post a bunch of tasks and then expect other people to do all the work for you...

See also:
https://www.cplusplus.com/doc/tutorial/program_structure/
https://www.cplusplus.com/doc/tutorial/files/
https://www.cplusplus.com/doc/tutorial/functions/
Last edited on
Have you first designed the program? Have you detailed the process of providing what is required? How would you do these using pen/paper? What instructions would you give some else to undertake these who didn't know the requirement.

Once you have the design, then you start to code from the design.

Assuming you have the designs, what part of c++ are you having trouble with? Post your current code.
build small and test often.
take only the first one until it is done, ignore the second.
write your function... its like 1 line of code... then test it with some easy values.
1
2
3
4
5
6
7
8
9
10
11
double CalNetPay (double hours, double pay)
{
   return hours*pay; 
}

int main()
{
   cout << CalNetPay(0.0,12.34) << endl; //0
   cout << CalNetPay(1.0,12.34) << endl; //12.34
   cout << CalNetPay(5.1,10.0) << endl;  //51.0
}


and so on. Once that piece is working and you are happy, work on reading the file.
just read it and echo what you got from the file to the screen, and verify it matches the file (look at the file in notepad or something). Once you can read the file properly, push what you got through your function... test that.... add a little, test a little, repeat until its all there, then test the whole thing again start to finish and make sure any testing junk has been removed.
Topic archived. No new replies allowed.