Sign in to follow this  
Otupia

Some part i havent learnd, so I cant solve it

Recommended Posts

Exercise : Given the diagram below. Transform the diagram into C++ program. Class Grade Private members :char letter;float score; Public Members :void SetScore( float );float GetScore( );char CalculateGrade ( ); Class Test Private members :int NumberOfQuestion;float PointsEach;int NumMiss; Public Members :Test( int, int ); Grade is given using the table below : > 89 A > 75 B > 60 C < 50 F Sample Program Output : How many questions are on the test? 20 [Enter] How many questions did the student miss? 3 [Enter] The score is 85 The grade is B -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- class grade { private: char letter; float score; public: void setscoce (float); float getscore (); char calculategrade(); }; save as 11.h #include<iostream.h> #include"c:\borlandc\bin\11.h" void grade::setscore(float n) { score = n; } float grade::getscore(); { return score; } char grade::calculategrade() { if (score>89) letter="A"; else if (score>75) letter = "B"; else if (score>60) letter = "C"; else if (score>50) letter = "F"; return grade; }; save as 11.cpp #include"c:\borlandc\bin\11.cpp" class test:public grade { private: int numberofquestion; float pointseach; int nummiss; public: test(int, int); }; ================================================================================ This is what I done so far, and the 3rd last time I cant solve it coz teacher havent tought us about it :S

Share this post


Link to post
Share on other sites
I'll help with some of the smaller errors, but we don't generally answer homework questions here. And, I doubt that the teacher would give you homework on something that you haven't been taught.

Where you have letter="A"; and all of those, because the variable 'letter' is a char, you need to use single quotes for the character you're assigning. Using quotation marks in C++ means a string, and you want a single letter.

I do reccommend that you see the teacher about the homework for more help.

Share this post


Link to post
Share on other sites
I'm going to bump this a bit: What part didn't the teacher explain?

All I can see is a program that's badly written with a lot of errors, without what you don't understand.

People will not fix your homework problems, they will help you explore how to fix it. If you say: I don't understand how to read from the standard input, people will help you on how to do read from the input, but will not write the code for it.

Be more specific, and you'll get help.

Toolmaker

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this