hi everyone, I'm still new to the programming world and I'm taking classes right now but I'm having some difficulty. I have a project that I need help creating and it requires to use functions. Up until now, we have been using pre-set functions but now we have to create them and I've been having issues trying to understand it. any help would be gratefully appreciated. I have what the final output is suppose to look like and I know how it should look, but when it comes to converting everything into a function (void, bool, etc...) I just end up confusing myself.
/* The program polls the user and collects the data regarding to their favorite 2008 presidency candidate. Once the user has stopped voting, the statistics on the topics are written to the screen. The user is given the option of taking the poll again, if he or she wishes.
This program should print your name, the program title, and the program objective to the screen. The output should be placed in a separate function. */
I need to have the table display the 5 choices and the number of times each option was selected and then show the percentage of each candidate. I haven't started building all the functions yet, I'm just trying build the program so it will function properly before I start creating the functions.
i'm currently doing the if statements to calculate the number of times each candidate was selected but somewhere along the lines, I can't get the calculations right
ok so this seems to keep count of each option to choose from including invalid options, now I need to calculate the percentage of each choice. (opinions appreciated)
sorry for all the back to back posts, its helping me think.
/********************************************************************
* Programmer: John Johnson
* Date: 8/19/2014
* Course: COMP 122
* Assignment: Final Project
* Description: The program polls the user and collects the data
* regarding to their favorite 2008 presidency candidate.
*
* Input: keyboard - choose your favorite candidate.
* Output: Displays the percentage of each choosen candidate
*******************************************************************/
#include <iostream>
#include <iomanip>
using namespace std;
void displayMenu()
{
cout << "Opinion Polls with Functions: \n";
cout << "*****************Opinion Polls***************** \n";
cout << "1. Hillary Clinton \n";
cout << "2. Barrack Obama \n";
cout << "3. John McCain \n";
cout << "4. Rallf Nader \n";
cout << "5. None of these are my favorite \n";
}
so everything appears to work the way it is suppose to, now the only thing left is to make it more efficient by creating another function. Any suggestions?