Honestly, I dont understand a thing in my C++ class T_T but this course is the core requirement so i cannot avoid taking it. Plz help me T_T I will appreciate it much!!!
This is the prompt:
ASSIGNMENT 2
Write a program that reads from a formatted file a list of 4 students and their grades for 3 tests, computes the average test score for each student and the class and the overall average for each test and for all tests and outputs them in a file
(in a special format).
The formatted input file contains on each line the name, student ID, and the grades for the 3 tests for a student (one
line per student). The format of the input file is the following:
STUDENTS
Student1LastName, Student1FirstNameInitial. Student1ID Student1TestAverage
Student2LastName, Student1FirstNameInitial. Student2ID Student2TestAverage
Student3LastName, Student1FirstNameInitial. Student3ID Student3TestAverage
Student4LastName, Student1FirstNameInitial. Student4ID Student4TestAverage
Class ClassAverage
TESTS
Test 1 Test1Average
Test 2 Test2Average
Test 3 Test3Average
Tests TestsAverage
where:
StudentXLastName is the last name of student X as read from the input file.
StudentXFirstNameInitial is the initial (first letter) of the first name of student X that you read from the input file.
StudentXID is the student X’s ID as read from the input file
StudentXTestAverage is the average between the student X's grades for Test1, Test2, and Test3.
ClassAverage is the average of the student test averages.
TestXAverage is the average of the student X's grades for Test1, Test2, and Test3.
TestsAverage is the average of the test averages.
The reminder values are constants and they should be outputted as they are.
The students and tests averages and overall totals should have exactly 2 decimals and should be aligned to the right. The
rest of the values should be aligned to the left. Make sure you are not missing any of the digits of the student ID. If you
are unable to determine the initial of the first name, you should use the first name instead (you will get partial credit
rather than 0). File1.txt and File2.txt are examples of input files that you can use to test your program.
For 5 points extra credit, change your program to read an optional middle name. Some students might have a middle
name while others might not have a middle name. Your program has to read names with both 2 words and 3 words (e.g.
Mary Smith, Mary Jane Smith). Your program should be able to distinguish between the 2 cases and read the data
appropriately (without confusing the last name for middle name, the last name for student ID, the student ID for test 1
grade, test 1 grade for test 2 grade, and so on). Do not output the middle name in the output file. You can use File3.txt
to test your extra credit part of the assignment.
You should use stream methods and manipulators rather than C++ features that we did not study in class like userdefined
functions, loops, arrays, string manipulation, etc.
What is the error you got? From what I could tell, when you read the data from inFile, right after studentFirstName and studentLastname; the next thing should be the 'studentID', and not studentTest1.. and so on...