Our C++ professor left us an assigment where we need to calculate the avearage grade of 5 students which data is stored in a .txt file.
i.e
Consider the following file format:
Q1,Q2,Q3,Q4,Q5,H1,H2, H3,H4,H4,MTE,FE
Q1,Q2,Q3,Q4,Q5,H1,H2, H3,H4,H4,MTE,FE
Q1,Q2,Q3,Q4,Q5,H1,H2, H3,H4,H4,MTE,FE
Where:
Q# is quiz score,
H# is homework score,
MTE is a midterm exam, and
FE is student’s score for the final exam.
The file with data for 5 students would look something like this:
36,72,58,76,81,73,67,82,38,79,81, 78
63,78,64,86,83,90,92,71,75,89,67, 98
90,88,78,89,91,93,87,92,98,89,85, 98
89,68,79,91,88,75,88,85,56,99,75, 81.
*each line is a different student
I have been looking in forums and web pages and there are good answers, but all of them use arrays or vectors, our professor doesnt want us to use them since this exercise should be the intro for arrays on next class.
my question is, how can I allocate this data in different variables so I can
work with them?***without using arrays or vectors***
Hello nuderobmonkey, salem c and dhyden. Thank you very much for your help. Nuderobmonkey, as dhyden said i had issues reading the data and dhyden, any time I run your code the cmd console is completly blank, I can type any number and press ENTER and the number disapear, also I noticed that in your code there is not IFSTREAM, and i need to open a file were the student grades are .
Again, thank you very much to all for the time and the help
If you want the program to open the file itself, add std::ifstream ifs("students_score.txt"); at the beginning of the program and then change cin to ifs throughout.