Hi everyone, i would like to use your help from my programming c++ assignmnet. am trying to do it, and i have to do this assignment because its my last hope to pass the course, because my dr. told me if i didnt do it correctly i will fail so please help me. i will post what the dr. wants and please please try to help me.
Thank you for ur time though

Objectives

1. Learn how to read in data from file.
2. Learn how to use arrays in conjunction with loops to solve standard data analysis problems.

Problem1: Donation Analysis

Money makes a difference in elections. With more money, a campaign can run more ads and hire more staff, giving the campaign an edge.
Due to your skills in programming, your boss has asked you to write a C++ program that helps in analyzing the recent campaign donations.

In particular, you will write a program that reads in information about these donations from a file. After reading in that data into your program, your program will provide the user with the following menu options:

1) Calculate the average donation for a subset of the donations.
2) Calculate the minimum donation for a subset of the donations.
3) Calculate the maximum donation for a subset of the donations.
4) Calculate the number of donations exceeding certain value.
5) Calculate the number of donations of a particular value.
6) Calculate what percentage of the donations are under certain value.
7) Quit

Your program should allow the user to continue choosing these options and execute them until the user quits. (Note: The entire time the program is running, it will be making these queries on the same set of data that was originally read it at the beginning of the program.)

Input File Specification
The first line of the input file will contain a single positive integer, n, which is less than or equal to 100000. This specifies the number of donations stored in the file. Each donation follows, one per line. Each individual donation will be a positive integer less than or equal to 2300.

Output Specification
At the very beginning of your program, you should prompt the user for their input file.
Once that is read in, your program should print out a message with the following format:

The data for n number of contributions has been read.

where n represents the total number of donations read from the file. These donations are numbered from 0 to n - 1.

Here is what your program should do for each of the following options:

#1) Prompt the user for the low bound for the subset of donations and the high bound for the subset of donations (you have to make sure that the user enters valid numbers, for this case and each of the following cases). Then produce an output message with the following format:

The average donation from person A to person B is X

where A is the low bound entered by the user, B is the high bound entered by the user and X represents the dollar amount (rounded to two decimal places) of the average donation by the group of people from person A to person B, inclusive.

#2) Prompt the user for the low bound for the subset of donations and the high bound for the subset of donations. Then produce an output message with the following format:

The smallest donation from person A to person B is X.

where A is the low bound entered by the user, B is the high bound entered by the user and X represents the amount of the minimum donation by the group of people from person A to person B, inclusive.

#3) Prompt the user for the low bound for the subset of donations and the high bound for the subset of donation. Then produce an output message with the following format:

The largest donation from person A to person B is X.

where A is the low bound entered by the user, B is the high bound entered by the user and X represents the dollar amount of the maximum donation by the group of people from person A to person B, inclusive.


#4) Prompt the user to enter a target value and then print out a message with the following format:

X people donated more than Y.

where X represents the total number of donations (from the whole file) that exceed Y dollars. (Note: Y is the value entered by the user.)

#5) Prompt the user to enter a target value and then print out a message with the following format:

X people donated exactly Y.

where X represents the total number of donations (from the whole file) that equal Y dollars. (Note: Y is the value entered by the user.)

#6) Prompt the user to enter a target value and then print out a message with the following format:

Donations under Y accounted for XX percent of the total funds raised.

where XX represents the percentage of the total donations (value-wise) rounded to two decimal places from donations under Y dollars.

Output Sample
Below is one sample output of running the program. Note that this sample is NOT a comprehensive test. You should test your program with different data than is shown here based on the specifications given above. In the sample run below, for clarity and ease of reading, the user input is given in italics while the program output is in bold.

The following file, "sample.txt", is used for the sample below.

sample.txt
10
50
25
75
2000
30
500
800
10
25
485


Sample Run
Please enter the name of the data file.
sample.txt
The data for 10 number of contributions has been read.

Please make a choice from the following options:
1) Calculate the average donation for a subset of the donations.
2) Calculate the minimum donation for a subset of the donations.
3) Calculate the maximum donation for a subset of the donations.
4) Calculate the number of donations exceeding a target value.
5) Calculate the number of donations of a particular dollar amount.
6) Calculate what percentage of the donations (value wise) are under a target value.
7) Quit
1

What is the low bound for your group (0-9)?
3
What is the high bound for your group (0-9)?
6
The average donation from person 3 to person 6 is $832.50.

Please make a choice from the following options:
1) Calculate the average donation for a subset of the donations.
2) Calculate the minimum donation for a subset of the donations.
3) Calculate the maximum donation for a subset of the donations.
4) Calculate the number of donations exceeding a target value.
5) Calculate the number of donations of a particular dollar amount.
6) Calculate what percentage of the donations (value wise) are under a target value.
7) Quit
2

What is the low bound for your group (0-9)?
3
What is the high bound for your group (0-9)?
6
The smallest donation from person 3 to person 6 is $30.

Please make a choice from the following options:
1) Calculate the average donation for a subset of the donations.
2) Calculate the minimum donation for a subset of the donations.
3) Calculate the maximum donation for a subset of the donations.
4) Calculate the number of donations exceeding a target value.
5) Calculate the number of donations of a particular dollar amount.
6) Calculate what percentage of the donations (value wise) are under a target value.
7) Quit
3

What is the low bound for your group (0-9)?
3
What is the high bound for your group (0-9)?
6
The largest donation from person 3 to person 6 is $2000.

Please make a choice from the following options:
1) Calculate the average donation for a subset of the donations.
2) Calculate the minimum donation for a subset of the donations.
3) Calculate the maximum donation for a subset of the donations.
4) Calculate the number of donations exceeding a target value.
5) Calculate the number of donations of a particular dollar amount.
6) Calculate what percentage of the donations (value wise) are under a target value.
7) Quit
4

What is the target donation?
75
4 people donated more than $75.

Please make a choice from the following options:
1) Calculate the average donation for a subset of the donations.
2) Calculate the minimum donation for a subset of the donations.
3) Calculate the maximum donation for a subset of the donations.
4) Calculate the number of donations exceeding a target value.
5) Calculate the number of donations of a particular dollar amount.
6) Calculate what percentage of the donations (value wise) are under a target value.
7) Quit
5

What is the target donation?
25
2 people donated exactly $25.

Please make a choice from the following options:
1) Calculate the average donation for a subset of the donations.
2) Calculate the minimum donation for a subset of the donations.
3) Calculate the maximum donation for a subset of the donations.
4) Calculate the number of donations exceeding a target value.
5) Calculate the number of donations of a particular dollar amount.
6) Calculate what percentage of the donations (value wise) are under a target value.
7) Quit
6

What is the target donation?
500
Donations under $500 accounted for 17.50 percent of the total funds raised.

Recommended Answers

All 9 Replies

http://www.daniweb.com/forums/announcement14-2.html
If ever a poster deserved to fail for such blatant attempts at cheating (or lack of effort), then yours is right up there!

> and i have to do this assignment because its my last hope to pass the course
And then what?

Getting a job on the back of faked qualifications because you managed to get others to do your homework?

Maybe you'll get promoted before you get sacked.

Or be a shoe buffer down the mall - there's a real shortage of shoe buffers round here.

emmm, Thank you very much.
and just so u know, i did not ask for ur help am asking for kind peopl to help, and guess what am not talking abt u

If you have questions more specific than "gimme the code", post them in the C++ forum.

I moved the thread (which was in Computer Science) to the C++ forum, when you were typing this reply :icon_redface:

Thank you though, but i dont want all of it, i just do get how i put the array and the loop to get to work together.
Thank you :D

Thank you though, but i dont want all of it, i just do get how i put the array and the loop to get to work together.
Thank you :D

First create an array, such as int myarray[10]; . Open a file and read data into each element of the array. Something like this: but your requirements may be a little different, I don't know because I didn't bother to read all that stuff.

int myarray[10];
ifstream in("filename.txt");
for(int i = 0; i < 10 && in >> myarray[i]; i++ )
   ;

Some basic tips:

1) File I/O tutorials can be found in the web. (Search "C++ File io tutorial")

2) Arrays and For loops go together llike peanut butter and jelly.

3) Apply a switch statement for the MCQ

4) Create some functions (eg. a "min" function to return the min value of an array)

5) Encase the whole thing in a do-while loop

Hope this is helpful.

Im dr. Abeer!!! You are plagiarizing, i will get your ip address and track you down whoever you are! You will fail this course and probably be expelled from the university!

Im dr. Abeer!!! You are plagiarizing, i will get your ip address and track you down whoever you are! You will fail this course and probably be expelled from the university!

Not from DaniWeb because nobody here is going to do his homework for him.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.