[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

C++ Assignment

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 27
Thread images: 1

File: cpp_logo.png (23KB, 360x405px) Image search: [Google]
cpp_logo.png
23KB, 360x405px
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++
>>
>>61429339
See
>>61429359
>>
>>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
Thread posts: 27
Thread images: 1


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.