Hello,
Schould I write a programm which only stores the names and the grades of a student. Or must I do some calculation with it.
For a Dutch person who's don't speak English very well it's a difficult book to follow.
Roelof
Hello,
Schould I write a programm which only stores the names and the grades of a student. Or must I do some calculation with it.
For a Dutch person who's don't speak English very well it's a difficult book to follow.
Roelof
Please state the problem.
"If you tell the truth, you don't have to remember anything"
-Mark Twain
Hello,
The problem is that I think I donīt understand what the exercise wants.
Roelof
I think he meant to state the exercise. Otherwise, we can't help you.
Surely someone in Holland has written a book for C++ beginners in Dutch? I couldn't find any with google, but then of course I entered "C++ books Dutch" which I think the Dutch word for Dutch has more oo's in it.
On the other hand, if you're getting into programming, I guess you might as well improve your English reading skills, since it would seem that everyone else who got into programming did not bother later to produce native language docs for their fellows -- big shame IMO.
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge
Oke,
The exercise is ;
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.
Roelof
Hmmm, I would say then your previous exercise experience will come in handy, because that also used "parallelism" in the vectors.
So this one will be similar, but slightly more complicated. Rather than a count of the words in the first vector, the second vector will be an average of the grades received by that student. In other words, yes you need to do a calculation: average the grades.
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge
MK27: No, actually, the Dutch word for Dutch doesn't have a single O in it :P.
Let me translate the problem...
Schrijf een programma die cijfers bijhoudt voor verschillende studenten tegelijkertijd. Het programma zou twee vectoren tegelijkertijd kunnen bevatten: de eerste zou de namen van de studenten bevatten, en de tweede de uiteindelijke cijfers die berekend kunnen worden terwijl de invoer gelezen wordt. Voor deze opgave moet je aannemen dat het aantal huiswerk cijfers van te voren bekend is (dat is, vast staat).
There. Does it make more sense now..?
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge
Oke,
So i have to write a programm which write students name to a vector and another vector who contains the average of that student (the average of the inputted numbers) .
Thatīs not to difficult or do I still mistaken
EVEEx , are you a Dutch person.
Roelof
Pretty sure s/he's from outer space, but you can always "Post Message" here:
http://cboard.cprogramming.com/member.php?u=33651
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge
Hello,
I need your help one more time.
I have this a code :
I wonder why the numbers don't add up.Code:#include <algorithm> #include <iomanip> #include <ios> #include <iostream> #include <string> #include <vector> using namespace std ; vector <string> names ; vector < double> grades ; typedef vector<double>::size_type vec_sz; vec_sz size ; typedef vector<double>::size_type vec_sz; vec_sz size2 ; double grade=0 , mid=0 , totaal=0 ; int teller, teller2, begin, eind ; int main() { // ask for and read the student's name cout << "Please enter the first name: "; string name; while (cin >> name) { cout << "Hello, " << name << "!" << endl; names.push_back (name); vector<double> homework; double x; for (teller = 0 ; teller < 5 ; teller++ ) { cout << "Enter the " << teller +1 << "th grade : " ; cin >> grade ; grades.push_back(grade) ; } cout << endl ; cout << "Please enter the next name: "; string name; } // compute the average homework grade of student and print it to screen size = names.size(); for (teller=0; teller < size ; teller++) { begin=teller*5 ; eind=begin+4 ; for ( teller2 == begin ; teller2 < eind ; teller2++); { totaal = totaal + grades[teller2]; cout << "Cijfer gevonden : " << grades[teller2] << endl ; cout << "positie cijfer : " << teller2 << endl ; cout << "leerling nummer : " << teller << endl ; cout << "begin : " << begin << endl ; cout << "einde : " << eind << endl ; } mid = totaal / 5 ; totaal = 0 ; cout << "Student " << names [teller] << " has a average of " << mid << endl ; } return 0 ; }
The second for loop looks to start at 4 instead of 0.
Does anyone see why ??
Roelof
Last edited by roelof; 06-19-2010 at 03:57 AM.
Right... Well... Erm... Okay... Well, I tried to translate "fixed" in the sentence, but I couldn't find a good Dutch word. So I made it "[...] is know (that is, stays the same)". It's not really possible to translate, but basically it is "that is, stays the same" or "that is, is fixed". So yeah, quite Descartesque :P.
@roelof: Yeah, I'm Dutch. Or at least, it's my task of my alien tribe to learn to live as one, so we can invade it soon... (2012, I believe...)
Now, seriously:
Are you using Windows or Linux? In Linux I know EOF is ctrl+D, not ctrl+Z. ctrl+Z in Linux stops the program for a while (until you type either fg or bg or do something else with it). So try Ctrl+D. In Windows, I'm not sure what key combination is EOF...
But the while condition on your inner loop seems wrong:
I'm not sure it will always be true, but it definitely will be most of the time ;-).Code:teller*5+4
Also, the exercise states it's best to calculate the average as you read it, rather than after pushing all grades into the vector. So first read it, calculate the average, and push only that into the vector. That should make things easier.
Also, your indentation can be a lot better...
EDIT: I see you edited your post even before I was able to reply... Please make a new post on updates, as I have no idea what has changed now.
Hello EVOEx,
So read in 5 numbers by a loop and 5 variables then calculate the average and put this in a vector.
I will try to change the code for that .
Roelof
Hello EVOEx,
What do you think about this code
RoelofCode:#include <algorithm> #include <iomanip> #include <ios> #include <iostream> #include <string> #include <vector> using namespace std ; vector <string> names ; vector < double> grades ; typedef vector<double>::size_type vec_sz; vec_sz size ; string name ; double grade , totaal, mid; int teller ; int main() { // ask for and read the student's name cout << "Please enter the first name: "; while (cin >> name) { cout << endl ; cout << "Hello, " << name << "!" << endl; cout << endl ; names.push_back (name); // ask for and read the grades totaal = 0 ; for (teller=0; teller < 5 ; teller++) { cout << "Put in the " << teller +1 << "th grade : "; cin >> grade ; totaal = totaal + grade ; } // calculate the average of that student mid = totaal / 5 ; // put these value into the vector grades.push_back (mid); cout << endl ; cout << "Please enter the next name: "; } // print out the data cout << endl ; size = names.size(); for (teller=0 ; teller < size ; teller++) { cout << "Student " << names[teller] << " has a average of " << grades[teller] << endl ; } return 0 ; }