In my class we were suposed to write a program from the book that inputed the names and votes and the program is suposed to spit out who won the vote. I did this then while i was reading the assignment from the instructor I noticed he wanted the information inputed from a TXT file instead of manually inputing it. I cannot seem to get it to work can anybody help me with this?
int main()
{
get_input();
calculate_winner();
calculate_Percentage_Of_Every_Candidate();
show_output();
return 0;
system("pause");
out.open("week8out.txt");
while (out)
{
out << names << "\t\t" << votes << "\t\t" << percentageVotes << endl;
out << endl;
out << "Winner of the election: " << names[winnerPos];
system("pause");
}
while(out.eof())
out.close();
}
here is the txt file
Johnson 5000
Miller 4000
Duffy 6000
Robinson 2500
Ashtony 1800
As your code as shown now, it is unreadable because the indentation was not preserved. If you put [code] before your code and [/code] after it with reasonable indentation, it can read. Or select your code and press on the <> button in Format: list. You are more likely to get help if you do that.