package cal;

import java.util.Scanner;

/**
 * The Class Calculator.
 */
public class Calculator {

    private Parser parser;

    public static void main(String[] args) {

        Calculator cal = new Calculator();

        String input = "";
        boolean isTryAgain = true;
        do {

            System.out.print("Enter: ");
            input = scanInput();

            isTryAgain = input.toLowerCase().equals("quit");

            cal.setInputExpression(input);
            System.out.println("Result:\n" + cal.execute() + "\n");

        } while (isTryAgain);

        System.out.println("Bye!");

    }

    public static String scanInput() {
        Scanner in = new Scanner(System.in);
        String input = in.nextLine();
        in.close();
        return input;
    }

    public void setInputExpression(final String input) {
        ParserFactory factory = new ParserFactory();
        factory = new ParserFactory();
        parser = factory.createParser(input);
    }

    public String execute() {
        return parser.execute();
    }

}

@@ -274,16 +274,25 @@
 = true;%0A
+        %0A
         
@@ -332,16 +332,40 @@
 t(%22Enter
+ (Type %5C%22quit%5C%22 to stop)
 : %22);%0A  
@@ -421,16 +421,17 @@
 Again = 
+!
 input.to
@@ -454,25 +454,70 @@
 ls(%22quit%22);%0A
+            
 %0A
+            if(isTryAgain) %7B%0A    
             
@@ -543,24 +543,28 @@
 ion(input);%0A
+    
             
@@ -618,16 +618,30 @@
 + %22%5Cn%22);
+%0A            %7D
 %0A%0A      
@@ -835,28 +835,8 @@
 ();%0A
-        in.close();%0A
     

Fix input loop error