Sep 9, 2009 at 6:04pm UTC
#include <iostream>
#include <string>
using namespace std;
Struct studenttype{
string firstname;
string lastname;
unsigned studentnumber;
unsigned numberofunits;
unsigned gradepoints;
};
void output(const studenttype & student_info);
void takeclass(studenttype & student, int unitstaken, char grade);
int main (){
studenttype studentone = {"John", "Smith", 123456789, 0, 0 };
studenttype studenttwo = {"Mary", "Jones", 123456790, 6, 24};
output(studentone);
output(studenttwo);
takeclass(studentone, 3, 'A');
takeclass(studenttwo, 4, 'B');
}
void output(const studenttype & student_info){
cout << student_info.firstname << student_info.lastname << ", #" << student_info.studentnumber << ": " << student_info.numberofunits
<< " units and " << student_info.gradepoints << " grade points" <<endl;
}
void takeclass(studenttype & student, int unitstaken, char grade){
switch(grade)
{
case 'A':
student.gradepoints = student.gradepoints + (unitstaken * 4);
break;
case 'B':
student.gradepoints = student.gradepoints + (unitstaken * 3);
break;
case 'C':
student.gradepoints = student.gradepoints + (unitstaken * 2);
break;
case 'D':
student.gradepoints = student.gradepoints + (unitstaken * 1);
break;
case 'F':
student.gradepoints = student.gradepoints + (unitstaken * 0);
break;
default:
count << grade << " is not a valid letter grade" << endl;
return;
}
student.numberofunits = student.numberofunits + unitstaken;
}
Sep 9, 2009 at 6:08pm UTC
No! But I can tell you how to use code tags! When you go to type a new post, look to the right. You will see a button with a # on it, directly under the word "Format: ". If you click it, inside the text box, [co de][/co de] will appear. If you click in between ] and [ and paste your code in there, I will bother to read it.
Sep 9, 2009 at 6:45pm UTC
It looks okay, but code verification usually involves actively running the program.
Do it do the right thing when you run it?
Sep 9, 2009 at 6:54pm UTC
i get like 50 errors. All i want to do is print to the screen student1's and student2's info to the using the output function. Then update the their info. with the takeclass function.
Sep 9, 2009 at 7:03pm UTC
Well, for one, the struct keyword is lowercase, not uppercase.
As for your other errors, try copying and pasting them here so we can see.
Sep 9, 2009 at 7:09pm UTC
lol. That got rid of all my errors. As you can see , i'm a newbie. thank you so much Ngen. Thanks goes out to chrisname and jsmith as well.