473,840 Members | 1,451 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

functions

Can someone help me work out this project? I need someone who is a
C++ expert to help me work this one out. Here it is below.

implement an abstract data
type (ADT) Student as a C++ class. The project
involves writing a program
that searches for duplicates in two files with lists
of student records. The
input files must be given sorted by student name.

I. The class has to be named Student and its
definition has to be in a file
named student.h.

The class has to store the components of the student
record in private
member data fields. The components should include
first name, last name, an
integer number of credits completed, and a floating
point grade point
average.

The class has to contain the following functions:

A function input() that reads in a student record
from a file. All the data
fields will be separated by at least one space. The
order of the fields is
first name, last name, credits, and grade point.

A function output() that writes out a student record
to the screen. The
function should output last name and first name
separated with a comma (note
that the last name has to be output first.)

A function lessThan() that compares two students.
Only the names are
compared. The last name is more significant than the
first one.

A function equals() that compares two students. Only
the names are compared
as with the lessThan() function.
The bodies of the above functions should be in a
file called student.cpp.

II. The program has to search for duplicates in two
files that contain lists
of student records. The input files must be in
sorted order by student name.

This program should contain two independent
functions described below:

The main() function, which calls the checkSorted()
function twice to verify
that each of the input files is sorted in strictly
ascending order. It then
performs the search operation. When a duplicate is
found the student record
from both files should be displayed, because
although the names will match
the other fields may be different. The output is to
be displayed on the
screen.

A function called checkSorted(), which accepts the
input stream as a parameter. This function should prompt the user for
the name of the input file. If the file cannot be opened, it should
continue to reprompt the user for the correct name, until the file can be opened.
The file should be read and it should verify that the file is in ascending
order. If it is not, an appropriate error message should be displayed and
the program should terminate. Otherwise, after the file has been
completely read, it should be closed and reopened to position it at the beginning of the file.

Jul 22 '05 #1
13 2211
"I. Dancay" <ha****@msn.com > wrote in message
news:64******** *************** ***@posting.goo gle.com...
Can someone help me work out this project? I need someone who is a
C++ expert to help me work this one out. Here it is below.

Wow! I am afraid not every C++ expert can help you with this complex task.
Looks like you need to ask for somebody from top10 world C++ programmers
http://www.top10cpp.com

Regards,
Slava

Jul 22 '05 #2
"I. Dancay" <ha****@msn.com > wrote in message
news:64******** *************** ***@posting.goo gle.com...
Can someone help me work out this project?
Yes we can help you. But what we will not do is
do your work for you. As soon as you have some
code, post it here and ask specific questions.
I need someone who is a
C++ expert to help me work this one out.
Your assignment does not require expert level C++
knowledge, but does require that you've paid attention
in class, taken notes, studied and practiced.
Here it is below.


[snip homework assignment].

-Mike
Jul 22 '05 #3
On 28 Sep 2004 09:48:39 -0700 in comp.lang.c++, ha****@msn.com (I.
Dancay) wrote,
Can someone help me work out this project? I need someone who is a
C++ expert to help me work this one out. Here it is below.


There are many C++ experts reading this group who will help you.
What results do you have so far? What specific questions do you have?

This issue is covered in Marshall Cline's C++ FAQ. See the topic
"[5.2] How do I get other people to do my homework problem for me?"
It is always good to check the FAQ before posting. You can get the FAQ
at:
http://www.parashift.com/c++-faq-lite/
Jul 22 '05 #4
"I. Dancay" wrote:

Can someone help me work out this project? I need someone who is a
C++ expert to help me work this one out.


Not really. In fact it is a typical homework assignment with
moderate complexity.

But it is this complexity which drives you nuts. This is because
you look at this assignment and say to yourself: Wow, I thats so
much work to do. I even don't know where to start!

Well. Start with the things you can do! The first thing you need
to do, is to derive a plan in which order you want to implement
(and test) things.

You certainly start with

int main()
{
}

That's always a good start :-)

Then you look t the assignment and discover that everything turns
around a 'student'. So you may ask yourself, what denotes a student?
Studying the assignment you figure out, that the description of a student
consists of
first name
last name
credits
grade points

and thats it.

Thus you can start to write (as requested by the assignment) in
a new file called student.h:

class student
{
private:
string first_name;
string last_name;
int credits;
double grade;
};

and you modify your main program to look like this:

#include "student.h"

int main()
{
}

When you try to compile this, you will notice that the compiler will
emit errors on the data type string. It dosn't know what a string
is, you have to tell it:

#include <string>

class student
{
private:
std::string first_name;
std::string last_name;
int credits;
double grade;
};

Compiling again, shows that this fixed the error.

You then continue with what you can write!
Looking through the assignment you see that there has
to be a function 'output()' that should output the
student information to cout. Well write it! I'll wait

To test this function you modify main()

#include <iostream>
#include "student.h"

int main()
{
student MyStudent;

MyStudent.outpu t();
}

Does it compile? Does it run?
No. Then fix any errors you get and try again.

You then continue in this way
The problem with newbies is, that they always think that
programmers write a program in one big rush. They think
we sit down at the computer and are typing for hours, then
the compiler runs through the code, maybe one or two syntax
errors which are easily fixed and, hey, we have a working
program.

The truth is: nobody works that way.
Programmers work by implementing small pieces of the assignment
and testing those pieces. Only after one piece works, the next
piece gets implemented. This way we know, if a problem occours it
is most likely the last implemented piece which gives the problem.

You should work the same way. For now ignore seom details in the
assignment and concentrate on what you can implement. Use those
pieces to implement other pieces from the assignment until ...
well ... until the whole assignment is done.

--
Karl Heinz Buchegger
kb******@gascad .at
Jul 22 '05 #5

"I. Dancay" <ha****@msn.com > wrote in message
news:64******** *************** ***@posting.goo gle.com...
Can someone help me work out this project? I need someone who is a
C++ expert to help me work this one out. Here it is below.


I would like to do it all for you. Please tell me the name of your teacher
so I can give it directly to him (with your name on it of course.)
Jul 22 '05 #6
Karl Heinz Buchegger wrote:
"I. Dancay" wrote:
Can someone help me work out this project? I need someone who is a
C++ expert to help me work this one out.

Not really. In fact it is a typical homework assignment with
moderate complexity.

But it is this complexity which drives you nuts. This is because
you look at this assignment and say to yourself: Wow, I thats so
much work to do. I even don't know where to start!

Well. Start with the things you can do! The first thing you need
to do, is to derive a plan in which order you want to implement
(and test) things.

You certainly start with

int main()
{
}


Great post Karl!
I really like how you show the newbee to write a test program
first. I also liked the part where you wait for the OP to
write the output() method.

Nice job. I just wish I had the time to write like you.

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.l earn.c-c++ faq:
http://www.comeaucomputing.com/learn/faq/
Other sites:
http://www.josuttis.com -- C++ STL Library book

Jul 22 '05 #7
>
The problem with newbies is, that they always think that
programmers write a program in one big rush. They think
we sit down at the computer and are typing for hours, then
the compiler runs through the code, maybe one or two syntax
errors which are easily fixed and, hey, we have a working
program.

The truth is: nobody works that way.
Programmers work by implementing small pieces of the assignment
and testing those pieces. Only after one piece works, the next
piece gets implemented. This way we know, if a problem occours it
is most likely the last implemented piece which gives the problem.


When I was at Uni our accounts where limited to running the compiler six
times only in one day. The reason given was that if we spent enough time
planning our programs we would only need a couple of compiles to fix the
typos and then we would have a working program. This was said, as far as I
could tell, in all seriousness. My Uni was rubbish.

Great post.

John
Jul 22 '05 #8
Karl Heinz Buchegger wrote:
The problem with newbies is that they always think that
programmers write a program in one big rush.
They think we sit down at the computer and are typing for hours
then the compiler runs through the code
maybe one or two syntax errors which are easily fixed
and, hey, we have a working program.
That's pretty much the way that I do it.
The truth is: nobody works that way.


Please speak for yourself.
Jul 22 '05 #9

"John Harrison" <jo************ *@hotmail.com> wrote in message
news:2r******** *****@uni-berlin.de...

The problem with newbies is, that they always think that
programmers write a program in one big rush. They think
we sit down at the computer and are typing for hours, then
the compiler runs through the code, maybe one or two syntax
errors which are easily fixed and, hey, we have a working
program.

The truth is: nobody works that way.
Programmers work by implementing small pieces of the assignment
and testing those pieces. Only after one piece works, the next
piece gets implemented. This way we know, if a problem occours it
is most likely the last implemented piece which gives the problem.


When I was at Uni our accounts where limited to running the compiler six
times only in one day. The reason given was that if we spent enough time
planning our programs we would only need a couple of compiles to fix the
typos and then we would have a working program. This was said, as far as I
could tell, in all seriousness. My Uni was rubbish.


Wow. Did they also tell you that you can only use the backspace/delete key 6
times per file so you can have all your code perfect on paper first? :-)
Jul 22 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
3354
by: hokiegal99 | last post by:
A few questions about the following code. How would I "wrap" this in a function, and do I need to? Also, how can I make the code smart enough to realize that when a file has 2 or more bad charcters in it, that the code needs to run until all bad characters are gone? For example, if a file has the name "<bad*mac\file" the program has to run 3 times to get all three bad chars out of the file name. The passes look like this:
99
5947
by: David MacQuigg | last post by:
I'm not getting any feedback on the most important benefit in my proposed "Ideas for Python 3" thread - the unification of methods and functions. Perhaps it was buried among too many other less important changes, so in this thread I would like to focus on that issue alone. I have edited the Proposed Syntax example below to take out the changes unecessary to this discussion. I left in the change of "instance variable" syntax (...
21
746
by: Rubén Campos | last post by:
I haven't found any previous message related to what I'm going to ask here, but accept my anticipated excuses if I'm wrong. I want to ask about the real usefulness of the 'inline' keyword. I've read many authors (and it's my belief, too) who discourage the use of the 'inline' keyword, because: - The 'inline' word only advice the compiler about wich functions should be expanded, but not force it to expand them. Also, the compiler can...
17
3637
by: cwdjrxyz | last post by:
Javascript has a very small math function list. However there is no reason that this list can not be extended greatly. Speed is not an issue, unless you nest complicated calculations several levels deep. In that case you need much more ram than a PC has to store functions calculated in loops so that you do not have to recalculate every time you cycle through the nest of loops. Using a HD for storage to extend ram is much too slow for many...
2
3799
by: Bryan Olson | last post by:
The current Python standard library provides two cryptographic hash functions: MD5 and SHA-1 . The authors of MD5 originally stated: It is conjectured that it is computationally infeasible to produce two messages having the same message digest. That conjecture is false, as demonstrated by Wang, Feng, Lai and Yu in 2004 . Just recently, Wang, Yu, and Lin showed a short- cut solution for finding collisions in SHA-1 . Their result
7
5912
by: Tim ffitch | last post by:
Hi I have created a VB dll file that contains common functions I use across various projects in VB, Access and Excel. Rather than have to code the functions in each I decided to use the dll route. The problem being that I can't call these functions from the query designer in Access. I decided that I would try the route of declaring the functions from the dll file the same way you would for the Windows API. Access then complains that...
23
4043
by: Timothy Madden | last post by:
Hello all. I program C++ since a lot of time now and I still don't know this simple thing: what's the problem with local functions so they are not part of C++ ? There surely are many people who will find them very helpfull. gcc has them as a non-standard option, but only when compiling C language code, so I'm afraid there might be some obscure reason why local functions are not so easy to be dealt with in C++, which I do not yet know.
14
4235
by: v4vijayakumar | last post by:
Why we need "virtual private member functions"? Why it is not an (compile time) error?
7
3977
by: Immortal Nephi | last post by:
My project grows large when I put too many member functions into one class. The header file and source code file will have approximately 50,000 lines when one class contains thousand member functions. Is it normal how C++ Compiler can compile large class without any problem? Didn't C++ Compiler have rules to limit the number of member functions? One big object has complex operations how member variables and member functions can be...
6
9622
KevinADC
by: KevinADC | last post by:
This snippet of code provides several examples of programming techniques that can be applied to most programs. using hashes to create unique results static variable recursive function serialization The code itself generates a list of strings comprised of random numbers. No number will be repeated within a string, and no string will be repeated within the list of strings. Following the code is a brief discussion of how the above...
0
9698
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
10916
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
10598
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
10299
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7022
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5684
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...
0
5872
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4071
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3136
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.