title: If statement within Case
body: <p>The following code generates different characters based on choices taken by the user previously using a bool function. The user can choose whether or not to have some of the characters, such as "numbers" or "Uppercase characters".</p>
  
  <p>The issue I'm having is that after I've implemented a <em>switch/case</em> system to <em>fully</em> randomize which character goes first, the choices aren't respected anymore.</p>
  
  <p>Per example, the user can choose numbers off, yet sometimes numbers will still show up in the sequence. This does <em>not</em> occur with the switch taken off for randomization purposes (which keeps the sequence to <em>Lowercase</em>+<em>Uppercase</em>+<em>Symbols</em>+<em>Numbers</em>).</p>
  
  <p>Should I be using if/else here, or is something else most likely wrong with the rest of the code?</p>
  
  <pre><code>int randomCharacter_cases;
  for(int i=0; i&lt;100; i++)
  {
      // If no appropriate option was selected, then the user will go back to selection:
      if(StrongPass==0 &amp;&amp; lowercase==0 &amp;&amp; Uppercase==0 &amp;&amp; numbers==0 &amp;&amp; symbols==0)
      {
          // CODE
      }
  
  
      // This selects the order of each character:
      randomCharacter_cases=rand()%4+1;
  
      switch(randomCharacter_cases)
      {
      // Lowercase characters;
      case 1:
      {
          if(StrongPass==1 || lowercase==1)
          {
              keeper.push_back((char)(rand()%(122-97+1)+97));
          }
          break;
      }
      // Uppercase characters;
      case 2:
      {
          if(StrongPass==1 || Uppercase==1)
          {
              keeper.push_back((char)(rand()%(90-65+1)+65));
          }
          break;
      }
      // Symbols;
      case 3:
      {
          if(StrongPass==1 || symbols==1)
          {
              keeper.push_back((char)(rand()%(64-33+1)+33));
          }
          break;
      }
      // Numbers;
      case 4:
      {
          if(StrongPass==1 || numbers==1)
          {
              keeper.push_back((char)(rand()%(57-48+1)+48));
          }
          break;
      }
  
      }
  
  }
  </code></pre>
  
  <p>EDIT: StrongPass, in this particular piece of code, is done in the case where the user doesn't wish to choose what characters he doesn't generate (for example, you may choose any of the four char. types, or you may simply say that you want an automatically generated password, which uses all four types of characters).</p>
  
  <p><strong>This</strong> is the function used to determine each individual usage:</p>
  
  <pre><code>bool yesno()
  {
  string inp;
  cin&gt;&gt;inp;
  if(!(inp=="Y" || inp=="y" || inp=="N" || inp=="n"))
  {
      cout&lt;&lt;"Y or N:";
      yesno();
  }
  if(inp=="Y" || inp=="y")
      return 1;
  else
      return 0;
  }
  </code></pre>
  
  <p>EDIT: Usage example:</p>
  
  <pre><code>// Choices we take for each password option:
  bool StrongPass,lowercase,Uppercase,symbols,numbers;
  
  // Function for generating random numbers:
  srand (time(NULL));
  
  // Default strong options, for easy use:
  cout&lt;&lt;"Would you like an automatic S.T.R.O.N.G. password?: ";
  StrongPass=yesno();
  
  // If you'd like a more advanced password:
  if(StrongPass==0)
  {
      cout&lt;&lt;"Length of the password?: ";
      cin&gt;&gt;length;
      cout&lt;&lt;"Length of the password?: "&lt;&lt;length&lt;&lt;"\n";
      cout&lt;&lt;"Include lowercase characters?: ";
      lowercase=yesno();
      cout&lt;&lt;"Include uppercase characters?: ";
      Uppercase=yesno();
      cout&lt;&lt;"Include symbols?: ";
      symbols=yesno();
      cout&lt;&lt;"Include numbers?: ";
      numbers=yesno();
  }
  
  // The password itself is generated here:
  int randomCharacter_cases;
  for(int i=0; i&lt;100; i++)
  {
      // This selects the order of each character:
      randomCharacter_cases=rand()%4+1;
  
      switch(randomCharacter_cases)
      {
      // Lowercase characters;
      case 1:
      {
          if(StrongPass==1 || lowercase==1)
          {
              keeper.push_back((char)(rand()%(122-97+1)+97));
          }
          break;
      }
      // Uppercase characters;
      case 2:
      {
          if(StrongPass==1 || Uppercase==1)
          {
              keeper.push_back((char)(rand()%(90-65+1)+65));
          }
          break;
      }
      // Symbols;
      case 3:
      {
          if(StrongPass==1 || symbols==1)
          {
              keeper.push_back((char)(rand()%(64-33+1)+33));
          }
          break;
      }
      // Numbers;
      case 4:
      {
          if(StrongPass==1 || numbers==1)
          {
              keeper.push_back((char)(rand()%(57-48+1)+48));
          }
          break;
      }
  
      }
  
  }
  </code></pre>