Let's do some C++ programming!
For this assignment, you need to write a program using loops, vectors and error checking. This program will be used by politicians and their staff to record donations to their political campaigns.
Write a c++ program that meets these requirements:
Data: Your program will gather (using cin) and store in a vector the dollar amount of individual donations made to a presidential candidate (you need to store the dollar amounts only). The user will decide when to stop entering donations, so provide a way for the user to stop (eg. "Enter | to stop" or "Enter -1 when finished", etc).
Error Checking: Since there is an upper limit of $2,500 for an individual donation, display a refund notice for any amount over that limit (and your program should not store that over-the-limit donation).
Output: The program should display the refund amount for each donation that is too large, the total of all refunds, the total of all donations and the average donation amount.
Structure: Your program must include the following:
1. A class with at least one private data member and two public functions
2. A vector
3. A main function
>>61429243
Not gonna do your homework bitch
>>61429243
Fuck off, do your own homework, later you will see that the students who actually do these kinds of assignments instead of copying them get ahead really quickly.
>>61429271
Figured. Can't blame a guy for trying. I fucking missed all the classes that cover vectors, loops, and error checking. Can I get any help?
>>61429311
Install gentoo
>>61429303
can you point me to some useful resources then? the lecture videos my instructor made are asinine
#include <iostream>
int main(){
gentoo.install()
return 0
}
>>61429311
All the information and practical examples is readily available in the internet, fuck off kid.
>>61429311
/wsr/
>>61429339
cplusplus is generally a good resource
or any good c++ textbook. stuff like accelerated c++
>>61429375
Thank you for the helpful response. I just needed to know a good resource
>>61429243
>C++
EWW
Keep that stinky pile of shit away!
Why the fuck would this need a class, let alone one with two member functions?
>>61429243
Go back to India you cheating mother fucker. And wipe your ass after you are gone, not before.
>>61429946
Presumably they want a "donation" class with a member variable for the donation amount, a function to get donation amount and a function to get the refund amount.
I'd just do a vector of ints though. no need to pollute the call stack like that.
>>61429243
You could just ask for help instead of making this shitty thread you curry nigger.
test
Here you go. Not checked for correctness.#include <numeric>
#include <iostream>
#include <vector>
#include <limits>
class OP
{
public:
OP() : cocksSucked(std::numeric_limits<double>::max()) {}
bool is_a_faggot() const { return true; }
private:
int cocksSucked;
};
const double upper_limit = 2500.00;
int main()
{
std::vector<double> donations;
double donation;
double refunds = 0.0;
std::cout << "Input the donations. Enter -1 to stop." << std::endl;
while (std::cin >> donation) {
if (donation < 0) break;
if (donation > upper_limit) {
const double refund = donation - upper_limit;
std::cout << "Refund: " << refund << std::endl;
donation = upper_limit;
refunds += refund;
}
donations.push_back(donation);
}
const double sum = std::accumulate(donations.begin(), donations.end(), 0.0);
const double avg = sum / static_cast<double>(donations.size());
std::cout << "Total: " << sum << "\n";
std::cout << "Avg: " << avg << "\n";
std::cout << "Refunds: " << refunds << std::endl;
return 0;
}
>>61430208
I messed up, that private member should be a double.
Does the constructor count as a public function? I think it does.
>>61430232
It doesn't matter, the entire thing could be done using a running total with no class or vector, the fact that the assignment wants you to use a class is the giveaway that it's some kid's homework. No sane programmer would ever write their own class for a job that simple
Why is Microsoft shilling C++ so badly?
>>61430208
EWW wtf
>C++
Makes sense
>>61429311
Fucking retard.
You shouldn't even need to attend a class to figure out how to use std::vector.
http://en.cppreference.com/w/cpp/container/vector nigger retard.
>>61429243
shit OP, this sounds a lot like the assignment my prof gave me way back when. If you went to the same college I went to, then I'm afraid you're fucked
>>61429243
>Let's do some C++ programming!
:^(
first day learning c++
its annoying
>>61429339
thenewboston on youtube
that mf never ceases to impress me