title: if else statement and while loop
body: <p>Please have a look at the following code</p>
  
  <pre><code>namespace Funny
  {
      class QuesionsAndAnswers
      {
          private double firstNumber;
          private double secondNumber;
          private double userAnswer;
          private double computerAnswer;
  
          private string operators;
  
          private bool answerCorrect;
          private bool enableDouble;
  
          private double[] listOfNumbers;
          private string[] listOfOperators;
  
          private Random randomizer;
  
          private static QuesionsAndAnswers qa;
  
          private QuesionsAndAnswers()
          {
              randomizer = new Random();
  
              listOfNumbers = new double[] { 1,2,3,4,5,6,7,8,9 };
              listOfOperators = new string[] { "+", "-", "*", "/" };
          }
  
          public static QuesionsAndAnswers getQuesionsandAnswersInstance()
          {
              if (qa == null)
                  qa = new QuesionsAndAnswers();
               return qa;
          }
  
          public string generateQuestions()
          {
              string result = "";
  
              operators = listOfOperators[randomizer.Next(listOfOperators.Length)];
              firstNumber = listOfNumbers[randomizer.Next(listOfNumbers.Length)];
              secondNumber = listOfNumbers[randomizer.Next(listOfNumbers.Length)];
  
              if ((operators.Equals("/")) &amp;&amp; (enableDouble == false))
              {
                  while (firstNumber % secondNumber == 0)
                  {
                      firstNumber = listOfNumbers[randomizer.Next(listOfNumbers.Length)];
                  }
                  result = firstNumber + operators + secondNumber;
              }
              else if (operators.Equals("-") &amp;&amp; (firstNumber&lt;secondNumber))
              {
                  while (firstNumber &gt; secondNumber)
                  {
                      firstNumber = listOfNumbers[randomizer.Next(listOfNumbers.Length)];
                      secondNumber = listOfNumbers[randomizer.Next(listOfNumbers.Length)];
                  }
                  result = firstNumber + operators + secondNumber;
              }
              return result;
          }
  
          public void setDoubleAnswers(bool check)
          {
              enableDouble = check;
          }
      }
  }
  </code></pre>
  
  <p>In here, in the generateQuestions() method, I am trying to generate some math questions. </p>
  
  <p>If operator in "-" and if the firstNumber &lt; secondNumber, then should  re generate numbers (first number and second number) to make sure the answer is not a minus value.</p>
  
  <p>And, if the operator is "/" and the boolean value is false, it should regenerate numbers again to make sure the the answer (which means the calculation, for an example 2/1 = 2) doesn't contain any floating points (which means it should not generate questions like 2/3, because the answer contains floating points).</p>
  
  <p>In my attempt, both above are not happening. It still generates unexpected answers or, sometimes nothing. Why is that? Please help</p>
  
  <p>Please note, I am a Java developer and this is my first major C# project.</p>