Another Problem

This program involves a for loop as well. But only has to record the score of team a and b for each quarter for a total of 4 quarters. I get it to compile, just getting some really big numbers. Any suggestions?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Lab0904.cpp - 
// Created by Taft Sanders on 10/12/12

#include <iostream>

using namespace std;

int main( )
{
    int scoreA;
    int scoreB;
    int teamA;
    int teamB;
    
    for (int quarter=1; quarter<=4; quarter++)
    {        
        cout<< "What is the score of Team A: ";
        cin>>teamA;
        cout<< "What is the score of Team B: ";
        cin>>teamB;
        
        
    }
    
    scoreA=scoreA+teamA;
    scoreB=scoreB+teamB;
    
    cout<< "Final Scores: "<<endl;
    cout<< "Team A: "<< scoreA<<endl;
    cout<< "Team B: "<< scoreB<<endl;
    
    if (scoreA>scoreB)
    {
                       cout<<"Team A won!"<<endl;
    }
    if (scoreA<scoreB)
    {
                       cout<<"Team B won!"<<endl;
    }
    if (scoreA==scoreB)
    {
                       cout<<"Both teams had the same score"<<endl;
    }
        
system ("pause");
return 0;
}



What is the score of Team A: 25
What is the score of Team B: 20
What is the score of Team A: 22
What is the score of Team B: 24
What is the score of Team A: 20
What is the score of Team B: 31
What is the score of Team A: 29
What is the score of Team B: 28
Final Scores:
Team A: 1965596241
Team B: 2686820
Team A won!
Press any key to continue . . .
Ok I guess it just took a little longer playing and I would have figured it out. Thanks to anyone that may be working on this currently. I'll post the code for those that may care to critique my results.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Lab0904.cpp - 
// Created by Taft Sanders on 10/12/12

#include <iostream>

using namespace std;

int main( )
{
    int scoreA=0;
    int scoreB=0;
    int teamA;
    int teamB;
    
    for (int quarter=1; quarter<=4; quarter++)
    {        
        cout<< "What is the score of Team A: ";
        cin>>teamA;
        cout<< "What is the score of Team B: ";
        cin>>teamB;
        
    scoreA=scoreA+teamA;
    scoreB=scoreB+teamB;   
        
    }
    
    
    
    cout<< "Final Scores: "<<endl;
    cout<< "Team A: "<< scoreA<<endl;
    cout<< "Team B: "<< scoreB<<endl;
    
    if (scoreA>scoreB)
    {
                       cout<<"Team A won!"<<endl;
    }
    if (scoreA<scoreB)
    {
                       cout<<"Team B won!"<<endl;
    }
    if (scoreA==scoreB)
    {
                       cout<<"Both teams had the same score"<<endl;
    }
        
system ("pause");
return 0;
}



What is the score of Team A: 25
What is the score of Team B: 20
What is the score of Team A: 22
What is the score of Team B: 24
What is the score of Team A: 20
What is the score of Team B: 31
What is the score of Team A: 29
What is the score of Team B: 28
Final Scores:
Team A: 96
Team B: 103
Team B won!
Press any key to continue . . .
Topic archived. No new replies allowed.