The university election will start in few days … they decided to create a system that calculates the total number of votes and decide who won the election instead of counting the votes manually. There are three different groups (Hardee’s, KFC, and Krispy cream) who’ll participate in the election. The university will provide 10 boxes to carry the votes (5 boxes for the boys & 5 for the girls). You’ve been asked to create this system. Your system will read the number of votes for the participated groups from every single box (from a file) and then it should display the following information:
Comment has been collapsed.
Still not seeing an actual question here. This is your whole assignment. Is there a specific question to ask, or are you hoping someone just does the whole thing for you?
Comment has been collapsed.
It's like in MMO games, when someone says "Can I ask a question?" Yes, you just did. Spit it out already.
Or: "Can you help me with a mission?" It's not a meaningful question. Tell people WHICH mission so they know if they want to (or even can) help you.
If you want to ask a C++ question, ask it. Don't beat around the bush.
(Oh, and we know it's for your homework, not "a friend." That's got to be one of the oldest obfuscations in the book.)
Comment has been collapsed.
well yes this she sent me
using namespace std;
int main() {
const int boxes = 10;
const int groups = 3;
int votes [boxes][groups];
ifstream in;
in.open("votes.txt");
for (int r=0;r<boxes;r++){
for (int c=0;c<groups;c++)
{in>> votes[r][c];
cout << votes [r][c]<<endl;}}
return 0;
}
now idk what shes tryna do can u talk to her directly ? on fb shes on
Comment has been collapsed.
Doesn't look hard if she already did that code.
Just replace arrays with std:vector for easy result counting and add few loops in the end for boxes to pick highest count for each group.
Still can't understand what is 'runner up' is that the second place after winner?
Comment has been collapsed.
well, make a class for a box, give it a function to read from file (i assume the file is just a line for each vote which states the number a single person voted for and you got one file per box - if its different, just adapt the code)
class box
{
map<int32_t, int32_t> groups;
box(const string& fileName)
{
readVotes(fileName);
};
readVotes(const string& fileName);
{
fstream in;
in.open(fileName);
int32_t currentValue;
while (in >> currentValue)
{
groups[currentValue]++;
}
}
then in your main.cpp you just make a vector of boxes:
vector<box> boxes;
boxes.emplace_back(box("votes1.txt"));
...
then you can simply read out your information
Comment has been collapsed.
2 Comments - Last post 6 minutes ago by BattleChaing
0 Comments - Created 35 minutes ago by MeguminShiro
11 Comments - Last post 1 hour ago by MeguminShiro
23 Comments - Last post 1 hour ago by MeguminShiro
974 Comments - Last post 1 hour ago by MeguminShiro
5 Comments - Last post 1 hour ago by ayobnaj
20 Comments - Last post 1 hour ago by VinroyIsViral
199 Comments - Last post 6 minutes ago by SmokyMonki
115 Comments - Last post 8 minutes ago by VernoWhitney
128 Comments - Last post 18 minutes ago by YeOldeLancer
93 Comments - Last post 21 minutes ago by RobbyRatpoison
46 Comments - Last post 32 minutes ago by LittleBibo1
80 Comments - Last post 34 minutes ago by NewbieSA
14 Comments - Last post 34 minutes ago by someonequeer
okey hi everybody a friend of mine needs help with c++ if anybody could help ill be glad i hope people wont take it as begging.
Comment has been collapsed.