| RoushGT (1) | |
|
I am trying to make a program that compares the scores of two bowling groups. In bowling1.dat there are 7 scores and in bowling2.dat there are also 7 scores. I want to compare the first score in each one and tell who wins. This is what I have so far in the program: #include <iostream> #include <iomanip> #include <string> #include <cstdlib> #include <math.h> #include <fstream> using namespace std; int main(){ ifstream bowling1; ifstream bowling2; int value, scores, max; bowling1.open("bowling1.dat"); bowling2.open("bowling2.dat"); max = 0; while (bowling1>>value){ max++; } cout<<"How many scores do you want to compare? ("<<max<<" max)"; cin>>scores; for (int counter = 1; counter <= scores; counter++){ bowling1>>value; bowling2>>value; cout<<counter<<" "<<value<<endl; } bowling1.close(); bowling2.close(); return (0); } ____________________________________________________________________________ As of right now, this program only displays the scores of one of the files. That's it. Please help! :) | |
|
|
|
| AbstractionAnon (414) | |||
You're reading from each file into the same variable. The second read if overlaying the value from the first file. Also, I don't see any logic to determine the winner. PLEASE USE CODE TAGS (the <> formatting button) when posting code. It makes it easier to help you. | |||
|
|
|||