title: my program won't execute anything after the while loop
body: <p>I wrote this "calculator" and I want it to output the result after calculation but it won't for some reason !!<br>
  <strong>A sample input would be</strong><br>
  2<br>
  1 + 1 * 2 =  </p>
  
  <p><strong>And output will be</strong> 
  4  </p>
  
  <p>Thanks in advance  </p>
  
  <pre><code>import java.util.Scanner;
  
  
  public class Main {
  
  /**
   * @param args
   */
  public static void main(String[] args) {
      Scanner input=new Scanner(System.in);
      int n=input.nextInt();
      for (int i=0;i&lt;n;i++){
          int result=input.nextInt();
          String operand=input.next();
          int flag=0;
          while (flag==0){
              int temp=input.nextInt();
              if (operand.equals("*"))
                  result*=temp;
              else if (operand.equals("/"))
                  result/=temp;
              else if (operand.equals("+"))
                  result+=temp;
              else if (operand.equals("-"))
                  result-=temp;
              else if (operand.equals("=")){
                  flag=1;
                  System.out.println(result);
              }
              operand=input.next();
          }
      }
  
  }
  
    }
  
  public class Main 
  {
      public static void main(String[] args) 
      {
           Scanner input=new Scanner(System.in);
           int n=input.nextInt();
           for (int i=0;i&lt;n;i++)
           {
               int result=input.nextInt();
               String operand=input.next();
               int flag=0;
               while (flag==0)
               {
                   int temp=input.nextInt();
                   if (operand.equals("*"))
                       result*=temp;
                   else if (operand.equals("/"))
                       result/=temp;
                   else if (operand.equals("+"))
                       result+=temp;
                   else if (operand.equals("-"))
                       result-=temp;
                   else if (operand.equals("="))
                   {
                       flag=1;
                       System.out.println(result);
                   }
              operand=input.next();
              }
          }
      }
  }
  </code></pre>