output

This is a sample C++ program that I found. I wanted to compile it to see if I could get to run, but I encountered some errors. I typed the program exactly as it appeared, but it doesn't work.

#include<iostream.h>
#include<string.h>
class student
{
public:
char fname[10],lname[15],major[10];
float semhours,credits;
void add_s(char *fn,char *ln,char *maj,float horus,float creds)
{
strcpy(fname,fn);
strcpy(lname,ln);
strcpy(major,maj);
semhours=hours;
credits=creds;
}
void show_info()
{
float gpa;
gpa=credits/semhours;
cout<<fname<<""<<lname<<"GPA:"<<gpa;
cout<<"Major:"<<major<<endl;
}
void addcourse(char xgrade,float hours)
{
float gpa;
if (xgrade=='a')credits=credits+(hours*4);
else if (xgrade=='b')credits=credits+(hours*3);
else if (xgrade=='c')credits=credits+(hours*2);
else if (xgrade=='d')credits=credits+(hours*1);
else credits = credits +0;
semhours = semhours + hours;
gpa = credits/semhours;
cout<<"Added course for "<<fname<<""<<lname;
cout<<"New GPA:"<<gpa<<endl;
}
};
int main (void)
{
student jane,john;
jane.add_s("Jane","Smith","Math",6,12);
john.add_s("John","Doe","English",9,28);
jane.show_info();
jane.addcourse('a',3);
john.show_info();
john.addcourse('c',3);
return 0;
}

A:\student.cpp(13) : error C2065: 'hours' : undeclared identifier
A:\student.cpp(13) : warning C4244: '=' : conversion from 'int' to 'float', possible loss of data
cbrookhartAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

_lychee_Commented:
u misspelt hours in ur function declaration as horus... that's the only mistake i can see from ur compile errors...

have fun! :)
0
cbrookhartAuthor Commented:
Thanks. I didn't see that spelled hours wrong.
0
_lychee_Commented:
whenever u get these undeclared identifier thingies i think most of the time (for me at least :>) it's due to some spelling error or another... just keep that in mind ok?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.