writing a program where i have to read in grade and credit hour values to calculate gpa.
this is my input txt file
ID# Grade cr hrs Grd cr hrs Grd cr hrs Grd cr hrs Grd cr hrs
30713 4 3 3 4 3 3 2 3 4 3
21356 4 4 4 3 3 3 2 3 2 3
21265 4 1.5 3 3 3 0.5 2 3 3 3
19364 4 3 3 3
19335 0 3 0 4 2 3 3 1.5
18264 2 3 3 0.5 3 0.5 3 3 2 3
20135 4 1 3 4 3 1.5 0 3
22185 4 3 4 4 4 3 3 3 4 3
this is how it looks in the input file on c++
1 2 3 4 5 6 7 8
|
30713 4 3 3 4 3 3 2 3 4 3
21356 4 4 4 3 3 3 2 3 2 3
21265 4 1.5 3 3 3 0.5 2 3 3 3
19364 4 3 3 3 -1 -1 -1 -1 -1 -1
19335 0 3 0 4 2 3 3 1.5 -1 -1
18264 2 3 3 0.5 3 0.5 3 3 2 3
20135 4 1 3 4 3 1.5 0 3 -1 -1
22185 4 3 4 4 4 3 3 3 4 3
|
the -1's are the sentinel values, where when it reads -1, the loop ends inside my while loop and moves to the next line.
How DO i read in grade and credit hours for each course
is it like this??
infile>>ID>>grade>>crhrs>>grade>>crhrs>>grade>>crhrs>>grade>>crhrs>>grade>>crhrs;