473,386 Members | 1,758 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Some part i havent learnd, so I cant solve it

1
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
Jun 12 '06 #1
1 1882
Banfa
9,065 Expert Mod 8TB
save as 11.h
This is very bad form try using meaningful names at all times for file names, class names, function names and variable names. For instance grade.h

#include"c:\borlandc\bin\11.h"
What are you doing saving the file in the c:\borlandc\bin directory. This is the directory that your IDE uses to keep it's binary (executable) files in. You will make it very messy if you put all your source files in there as well. Put your source files in a different directory made specially for the program you are writing.

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;
};
This wont work (probably wont compile either) grade is of type char (*)(void), i.e. is a pointer to a function taking no parameters and returning char. You need to return type char, I suspect you meant return letter;

save as 11.cpp
See comment above about using sensible meaningful file names.

#include"c:\borlandc\bin\11.cpp"
Including c code into headers is asking for trouble at the link stage with multiply defined symbols. You probably meant to include the header which would be reasonable.

and the 3rd last time I cant solve it coz teacher havent tought us about it :S
Sorry the first part of this does not make sense, what hasn't your teacher taught you?
Jun 13 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: Vibhajha | last post by:
Hi friends, My sister is in great problem , she has this exam of C++ and she is stuck up with some questions, if friends like this group provides some help to her, she will be very grateful....
10
by: blah | last post by:
i m currently in a network (LAN). i started python because i heard that it has great ability for networking programs and/or scripts, but i m losing my motivation with python because there are sooo...
193
by: Michael B. | last post by:
I was just thinking about this, specifically wondering if there's any features that the C specification currently lacks, and which may be included in some future standardization. Of course, I...
8
by: Mas L via DotNetMonster.com | last post by:
Hi, I have a c++ source code which I can compile to be a DLL (in VS.NET 2003). And I need to use it in a C# program. After I compiled/build the C++ code to a DLL, I add it as a Reference in my...
19
by: felixnielsen | last post by:
Some might remember that i, not so long ago, started a treath or two about a weird 3d labyrinth. I now have a working code, that i want to share, hear comments, advice, ect., but first let me...
20
by: mike | last post by:
I help manage a large web site, one that has over 600 html pages... It's a reference site for ham radio folks and as an example, one page indexes over 1.8 gb of on-line PDF documents. The site...
6
by: logieen | last post by:
Hi , Every one I really need some help in my programs it doesn't work as I want I know there something wrong in it if you know where the wrong is just show me plz as soon as Possible plzzzzz. I a...
10
by: mistb2002 | last post by:
I am trying to modify my program to add and delete inventory items. I tried just adding but I am getting mutliple errors help. This is what my program currently looks like // Display The...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.