J
Jeff Rollin
Hi group,
I'd like to solicit some advice on a problem I've been having with one of
the programs in Chapter 3 of Accelerated C++, viz:
"Write a program that will keep track of grades for several students at
once.
The program could keep two vectors in sync: The first should hold the
student's names, and the second the final grades that can be computed as
input is read. For now, you should assume a fixed number of homework
grades...".
The problems I'm having are as follows:
The "final grades" are computed as the sum of the ratio of midterm grades to
final exams grades to coursework grades; the ratio is irrelevant to this
problem and the book explicitly shows you how to do this. Where I'm having
difficulty is that I can't see how to gather (a) the midterms, (b) the
finals
and (c) the homework grades for (numbers of students > 1) without using a
vector for each of (a), (b) and (c) and then computing the grades from each
of the elements and storing the successive grades in another vector. As you
can see, using vectors for names, midterms, finals, homework and grades
brings us to not two vectors, as the book suggests, but five.
Some notes:
1) The attached source code has the problem that you end a line of input (in
the first case, a list of names such as:
Jeff Geoff
with either two EOF's or an LF followed by an EOF. This is as suggested thus
far through the book. However, once you've done that the program
automatically thinks you have passed input to the next variable (cin >>
midterms). The book has not yet tackled the problem of how to clear the
input
stream; I'm guessing that this is a failure of understanding on my part
since
the (rather detailed) list of Errata on the Website of the Book doesn't even
mention it.
2) I'm aware that some of the algorithms (e.g. for error checking) are not
optimal - I'm trying to resolve these problems using the tools as so far
given, w/o looking for solutions in later parts of the book.
Is it possible that the advice to "read the book over once" first and then
go
back and do the exercises is because the exercises from earlier chapters use
techniques defined in later ones?
TIA
Jeff
I'd like to solicit some advice on a problem I've been having with one of
the programs in Chapter 3 of Accelerated C++, viz:
"Write a program that will keep track of grades for several students at
once.
The program could keep two vectors in sync: The first should hold the
student's names, and the second the final grades that can be computed as
input is read. For now, you should assume a fixed number of homework
grades...".
The problems I'm having are as follows:
The "final grades" are computed as the sum of the ratio of midterm grades to
final exams grades to coursework grades; the ratio is irrelevant to this
problem and the book explicitly shows you how to do this. Where I'm having
difficulty is that I can't see how to gather (a) the midterms, (b) the
finals
and (c) the homework grades for (numbers of students > 1) without using a
vector for each of (a), (b) and (c) and then computing the grades from each
of the elements and storing the successive grades in another vector. As you
can see, using vectors for names, midterms, finals, homework and grades
brings us to not two vectors, as the book suggests, but five.
Some notes:
1) The attached source code has the problem that you end a line of input (in
the first case, a list of names such as:
Jeff Geoff
with either two EOF's or an LF followed by an EOF. This is as suggested thus
far through the book. However, once you've done that the program
automatically thinks you have passed input to the next variable (cin >>
midterms). The book has not yet tackled the problem of how to clear the
input
stream; I'm guessing that this is a failure of understanding on my part
since
the (rather detailed) list of Errata on the Website of the Book doesn't even
mention it.
2) I'm aware that some of the algorithms (e.g. for error checking) are not
optimal - I'm trying to resolve these problems using the tools as so far
given, w/o looking for solutions in later parts of the book.
Is it possible that the advice to "read the book over once" first and then
go
back and do the exercises is because the exercises from earlier chapters use
techniques defined in later ones?
TIA
Jeff