473,769 Members | 5,912 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Some part i havent learnd, so I cant solve it

1 New Member
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 NumberOfQuestio n;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<iostre am.h>
#include"c:\bor landc\bin\11.h"

void grade::setscore (float n)
{
score = n;
}
float grade::getscore ();
{
return score;
}
char grade::calculat egrade()
{
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:\bor landc\bin\11.cp p"

class test:public grade
{
private:
int numberofquestio n;
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 1905
Banfa
9,065 Recognized Expert Moderator Expert
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:\bor landc\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::calculat egrade()
{
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:\bor landc\bin\11.cp p"
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
2330
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. These are some questions:- 7. design and implement a class binsearch for a binary search tree.it includes search,remove and add options.make suitable assumption. 8.explai how pointers to functions can be declared in c++.under what conditions can...
10
1444
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 many modules, that i cant just learn them all, this deters from c or c++ in which there are only a limited number of header files. what loses my interest is that if i cant learn these modules, and there are lots and lots of python modules, how...
193
9638
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 speak only of features in the spirit of C; something like object-orientation, though a nice feature, does not belong in C. Something like being able to #define a #define would be very handy, though, e.g: #define DECLARE_FOO(bar) #define...
8
3615
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 C# program. When I look at the reference and I double click to view it in the objec browser , I see only structs , without their members. And I don't see methods.
19
2370
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 explain what its all about. The whole labyrinth is a cubic in its self and it contains x^3 cubic rooms. The labyrinth is infinite/finite, it has no borders, but still have a size. fx. if the size of the labytrint is 2^3 and you find yourself at
20
4284
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 is structured as an upside-down tree, and (if I remember correctly) never more than 4 levels. The site basically grew (like the creeping black blob) ... all the pages were created in Notepad over the last
6
1345
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 Beginner in C++ ; I will be thankful for you . ------------------------ first program : I need the user to enter his/her full name and then the program separate the string to first name , middle name and the last name which stored in three...
10
5856
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 DVDs. import java.text.*; import java.util.*; import java.awt.*; import java.awt.FlowLayout;
0
9415
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10198
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10032
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8860
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7392
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5293
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3947
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3551
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2810
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.