Welcome to Dream.In.Code
Become a C++ Expert!

Join 137,203 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,317 people online right now. Registration is fast and FREE... Join Now!




school help please

 
Reply to this topicStart new topic

school help please, program

ndyaa007
31 May, 2008 - 04:40 PM
Post #1

New D.I.C Head
*

Joined: 31 May, 2008
Posts: 1

i need help with the program below. so if any one could help me that woulp be appreciated. bc my teacher teaches nothing to use so i dont understand how to do this.please and thank you!!



Declare a structure that contains information on each donor. Include the donor's name, the donor's telephone number, and the money amount of their latest contribution. Assume an array of 300 structures.
(Hint: when writing the program, use an array of 3 or 4 for testing purposes).

Write functions to address each of the following requests:

a. sort the list according to the size of the donation, with the largest donation listed
first.
b. print the sorted list to the screen in some organized manner.
c. print to the screen in some congratulatory manner, the person giving the largest
donation. You must deal with the possibility that two (or more) people may have
given the same amount of money. You may assume for this problem that not more
than 3 people will give the same donation amount.
d. create a function that will receive the array by reference and will return the average
of all the donations. Print the average of the donations to the screen.

You may choose the best printing process. Be sure to label the information on the screen so that someone reading the screen will understand WHAT they are reading.

User is offlineProfile CardPM
+Quote Post

KYA
RE: School Help Please
31 May, 2008 - 04:57 PM
Post #2

#include <nerd.h>
Group Icon

Joined: 14 Sep, 2007
Posts: 5,049



Thanked: 124 times
Dream Kudos: 1200
My Contributions
Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Please post like this:

Thank you for helping us helping you.

...
User is online!Profile CardPM
+Quote Post

Martyr2
RE: School Help Please
31 May, 2008 - 04:59 PM
Post #3

Programming Theoretician
Group Icon

Joined: 18 Apr, 2007
Posts: 5,244



Thanked: 221 times
Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions
Well it is site policy that we see you have a "best effort" attempt at solving the problem yourself which we can then guide you with. However we can certainly get you started on the right path. The whole program is based around the idea of a structure.

Structures in C/C++ use the "struct" keyword. They describe data that is related to one another and form the idea of an object or container.

Here you need a struct called "donor" which has three member variables. One for the name, one for the telephone and one for the contribution.

It would look something like this...

cpp

struct donor {
char *name;
char *telephone;
double contribution;
};


As you can see we now have a structure called donor and three member items for each of the donor's attributes. Now this describes a donor and how one is structured. So now we need to create a donor like so...

cpp

donor Martyr2;

Martyr2.name = "Martyr2";
Martyr2.telephone = "444-555-5555";
Martyr2.contribution = 3400.00;

cout << Martyr2.name << " contributed " << Martyr2.contribution << " and is just kick ass altogether." << endl;


So once you get the idea of a donor down, you just need to put together functions which pass around variables of type "donor" and access the member items using the dot notation like mentioned above.

Good luck! smile.gif

"At DIC we be struct building code ninjas... we try to build structs with legos but they just wouldn't compile. MVC++ kept saying 'Error: stop being a dumbshit" decap.gif
User is online!Profile CardPM
+Quote Post

akozlik
RE: School Help Please
31 May, 2008 - 06:35 PM
Post #4

D.I.C Addict
Group Icon

Joined: 25 Feb, 2008
Posts: 615



Thanked: 24 times
Dream Kudos: 750
My Contributions
Regarding your sorting, check out google for bubble sort. It sounds like this is a beginner C class, so that should be sufficient. I believe you might even be able to find some sorting algorithms in the DIC Code Samples. Utilize your resources.

Damn, Martyr's ballin with the $3400 donation. Mind sending that to my paypal account?
User is online!Profile CardPM
+Quote Post

no2pencil
RE: School Help Please
31 May, 2008 - 08:39 PM
Post #5

My fridge be runnin OH NOEZ!
Group Icon

Joined: 10 May, 2007
Posts: 6,504



Thanked: 67 times
Dream Kudos: 2425
Expert In: Goofing Off

My Contributions
QUOTE(akozlik @ 31 May, 2008 - 10:35 PM) *

Damn, Martyr's ballin with the $3400 donation. Mind sending that to my paypal account?

Just call the phone number. That's what I did & I got twice that much!
User is offlineProfile CardPM
+Quote Post

Martyr2
RE: School Help Please
31 May, 2008 - 09:04 PM
Post #6

Programming Theoretician
Group Icon

Joined: 18 Apr, 2007
Posts: 5,244



Thanked: 221 times
Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions
Yeah I am just giving it away like a trailer park.... ummm... nevermind. pimp.gif
User is online!Profile CardPM
+Quote Post

KYA
RE: School Help Please
1 Jun, 2008 - 01:34 AM
Post #7

#include <nerd.h>
Group Icon

Joined: 14 Sep, 2007
Posts: 5,049



Thanked: 124 times
Dream Kudos: 1200
My Contributions
"Here at DIC we be giving away trailer parks." tongue.gif

This post has been edited by KYA: 1 Jun, 2008 - 01:50 AM
User is online!Profile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/4/08 12:27PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month