Help with Logic/Syntax

OK, I am writing a code that deals with American Football and the down and distance. What I want it the computer to do simple calculations of the down and distance. If you do not know football all to well, you may not be able to help.
I basically have it set up like this, there are 5 things that can happen on a play: a "gain", a "loss", an "int", a "fumble", and a "punt". But as you will see, the program asks the user for 3 pieces of input, "gainOrLoss" which asked which of the five happened, a string for the word "of", and an integer("gainLoss") for the amount of yards gained or lossed. What I would like the program to do if the "gainOrLoss" is "punt, int, or fumble" is give the output a first down and restart. I know the answer is right in front of me but I am struggling to grasped the logic/syntax of the issue. Any suggestions would be appreciated. Here is my code, there are some random cout's that tell me where the program is, you can ignore those:

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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#include <iostream>
#include <string>
#include <iomanip>
#include <stdlib.h>

using namespace std;

int main(){
    int down =1;
    int distance =10;
    string first = "st";
    string second = "nd";
    string third = "rd";
    string forth = "th";
    string abv;
    string gainOrLoss;
    string of;
    int gainLoss;
    if(down == 1){
               abv = first;
    cout << down << abv << " and " << distance << endl;
               }
    if(down == 2){
               abv = second;
               }
    if(down == 3){
               abv = third;
             }
    if(down == 4){
               abv = forth;
               }
   while (down<=4 ){  
   cout << "What happened on last play? " <<endl;
   cin >> gainOrLoss;
   cin >> of;
   cin >> gainLoss;  
   if(gainOrLoss == "loss"){
                 distance = distance + gainLoss;
                 down = down +1;
                    if(down == 1){
                               abv = first;                
                               }
                    if(down == 2){
                               abv = second;               
                               }
                    if(down == 3){
                               abv = third;                
                               }
                    if(down == 4){
                               abv = forth;               
                               }                                                         
                               }             
   if(gainOrLoss == "gain" && gainLoss < distance){
                 distance = distance - gainLoss;
                 down = down +1;                            
                    if(down == 1){
                               abv = first;
                               }
                    if(down == 2){
                               abv = second;
                               }
                    if(down == 3){
                               abv = third;
                               }
                    if(down == 4){
                               abv = forth;
                               } 
                               }         
   else if(gainOrLoss == "gain" && gainLoss >= distance){
                 down =1;
                 distance =10;
                   if(down == 1){
                               abv = first;
                               }
                    if(down == 2){
                               abv = second;
                               }
                    if(down == 3){
                               abv = third;
                               }
                    if(down == 4){
                               abv = forth;
                               }      
                               }       
   if(gainOrLoss == "gain"||"fumble"||"int"){
                 down =1;
                 distance =10;
                   if(down == 1){
                               abv = first;
                               }
                    if(down == 2){
                               abv = second;
                               }
                    if(down == 3){
                               abv = third;
                               }
                    if(down == 4){
                               abv = forth;
                               }      
                               }         
    if (down <=4){
               system("cls");
               cout << down << abv << " and " << distance << endl;     
               }                            
    else {
                   cout << "End Of Possession" <<endl;
                   getchar();
                   getchar();
                   return 0;
                   }        
}  
 cout << "lll" <<endl;
   getchar();
 getchar();

    return 0;
}
Last edited on
Topic archived. No new replies allowed.