title: Flow of execution questions
body: <p>I've been having trouble figuring this out for a while now. I keep having issues with my if/else if statements. In my program, I'm trying to loop a list of customer for a telemarketer to read off of and record the call information into another document. I'm only having two issues that I believe are relatively small and minor but I can't figure it out with my google fu.</p>
  
  <p>Here's my code: </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;cstdlib&gt;
  
  using namespace std;
  
  int main()
  {
      char stat, answ;
      float rate;
      string fname, lname, phone, address;
      ifstream potentials("C:\\Users\\Brandon\\Desktop\\C++Projects\\Lab6\\potentials.txt");
      ofstream results("C:\\Users\\Brandon\\Desktop\\C++Projects\\lab6\\results.txt");
  
      if (!potentials) {
          cerr &lt;&lt; "Unable to open file";
          exit(1);
      }
  
      while (!potentials.eof())
      {
          potentials &gt;&gt; stat &gt;&gt; fname &gt;&gt; lname &gt;&gt; phone;
  
          if (stat == 'X')
          {
              cout &lt;&lt; "customer is preferred\n";
              rate = .079;
          }
  
          if (stat != 'X')
          {
              cout &lt;&lt; "Customer is not preferred\n";
              rate = .129;
          }
  
          cout &lt;&lt; fname &lt;&lt; " " &lt;&lt; lname &lt;&lt; " " &lt;&lt; phone &lt;&lt; " " &lt;&lt; rate &lt;&lt; endl;
          cout &lt;&lt; "Is this customer interested in this card? Y or N" &lt;&lt; endl;
          cin &gt;&gt; answ;
  
          if (answ == 'Y')
          {
              cout &lt;&lt; "Thank the customer and ask for their current address.\n";
              cin &gt;&gt; address;
              cout &lt;&lt; "Thank the customer for accepting the offer, to expect a card in the mail soon, and happy charging!\n";
              results &lt;&lt; fname &lt;&lt; " " &lt;&lt; lname &lt;&lt; " " &lt;&lt; stat &lt;&lt; " " &lt;&lt; address &lt;&lt; " \r " &lt;&lt; endl;
          }
  
          if (answ == 'N')
          {
              if (stat == 'X')
              {
                  cout &lt;&lt; "Tempt them with the cash back rewards and to call 18003838383 for a better offer.\n";
                  results &lt;&lt; fname &lt;&lt; " " &lt;&lt; lname &lt;&lt; " " &lt;&lt; answ &lt;&lt; " " &lt;&lt; address &lt;&lt; " \r" &lt;&lt; endl;
              }
  
  
              else if (stat != 'X');
              {
                  cout &lt;&lt; "Tell them thank you anyhow and to have a nice day.\n";
                  results &lt;&lt; fname &lt;&lt; " " &lt;&lt; lname &lt;&lt; " " &lt;&lt; answ &lt;&lt; " " &lt;&lt;
                      address &lt;&lt; " \r" &lt;&lt; endl;
              }
          }
      }
  }
  </code></pre>
  
  <p>Problem number 1:</p>
  
  <p>For the address portion, I keep getting an error where if I include a normal address such as 123 w main st. That type of address will weirdly complete the loop. Like [so][1]. I don't know and understand why that happens. It will compile and execute just fine if I just put a number.</p>
  
  <p>Problem number 2:</p>
  
  <p>If the customer proceeds to call and decline the card, both the if statement and the else if statement will execute:</p>
  
  <pre class="lang-none prettyprint-override"><code>customer is preferred
  Joe SCholz 437-4798 0.079
  Is this customer interested in this card? Y or N
  Y
  Thank the customer and ask for their current address.
  123 W Main St
  Thank the customer for accepting the offer, to expect a card in the mail soon, and happy charging!
  Customer is not preferredTim Wade 768-7658 0.129
  Is this customer interested in this card? Y or N
  customer is preferredSara JObs 326-7857 0.079
  Is this customer interested in this card? Y or N
  Customer is not preferredJaynce Bee 354-8678 0.0129
  Is this customer interested in this card? Y or N
  </code></pre>
  
  <p>I don't understand this part either because the if statement should execute. If the customer doesn't have an X on their status in the file, then it should automatically go to the else if statement. Instead it executes both the if and the else if statement and I can't seem to figure out as to why that happens.</p>
  
  <p>These are the only two things holding me back and I can't figure out both of them.</p>