Help - Search - Members - Calendar
Full Version: Need help with a task(C++)
Pixel2Life Forum > Help Section > Desktop Programming
Extinct
I've got an easy task that I need help with. I started learning c++ today and I have no clue how to do this. I will pay a small amount of money through paypal if someone helps me with the code ;P

I want to write a voting program. It asks for how many yes votes, no votes and the number of "non decided" votes. That is the easy part that I know how to do, but when writing the code to calculate it I fail. If someone could provide me with a full example I will send you like 5 bucks or something ;P

The outline example looks like:

Amount of votes in percent:
==================
Yeah 20,500%
No 20,500%
Undecided 59,000%

PSgirl
I don't exactly understand what's the problem. So you already asked for the votes and already have them as variable in your program, don't you?

First of all, you need to add all them up to know how many votes you got in total. Then you calculate the percentage and you display them on screen. Something like this:

int total_votes=votes_yeah+votes_no+votes_undecided;
float per_yeah=votes_yeah / total_votes * 100; (the same with the others)

And then, use cout to display them on screen. I haven't programmed c++ in years, but if I remember correctly, it would be something like this:

cout << "Yeah" << per_yeah;

Just try to do these things on your own, you aren't going to learn c++ by paying someone else to do it. bigwink.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.