hi can you please help me with my assignment regarding fstream
i really need your help so please help me
The question is like:
A professor at a university has asked you to write a program which will calculate the percentage and print the student ID, percentage and letter grades for his class to an output file called grades.txt. The student’s details and course marks are stored in a data file called results.txt. The class strength is 10.
You are required to implement the code using functions:
Write a function that opens the results.txt for reading. It should test whether the file was opened correctly and if so, read in the 10 lines of data one by one into appropriate variables. The data values in the first column are stored in an integer array called StudentID, the data values from the second, third and fourth column are used to calculate the percentage which is then stored in a double precision array called Percentage.(i.e Percentage[i] = (Math + English + Physics)/3 ).
(Use the Function prototype: void readFile(int[], double[])).
Once all data is read and stored in the appropriate arrays, close the connection to the input file.
Write another function which will open the output file grades.txt for writing. You are to print out the student IDs, percentage and letter grades to the output file. Each student detail is to appear on a separate line of the file.
(Use the Function prototype: void writeFile(int[], double[])).
Once all data is written, close the connection to the output file.
The letter grades for each student could be determined using the information below:
Numerical Grade
Letter Grade
Greater than or equal to 90 A
Less than 90 but greater than or equal to 80 B
Less than 80 but greater than or equal to 70 C
Less than 70 but greater than or equal to 60 D
Less than 60 E
Note:
• Both the functions are to be called from the main().
• Include all appropriate header files.
• All numerical output must be formatted to display to two decimal places.
• Have appropriate commenting in your program and practice good programming skills. Your program should be well documented and user friendly.