hi i am having problem with the while loop termination. totally newbie......can you help me terminate the loop .... output

import java.io.*;
public class MohsinKPA4
{
    private static double num1;
    private static double num2;
    private static String Snum1;
    private static String Snum2;
    private static double ans;

    public static void main(String args[])throws IOException
    {
        String readinp;
        int func;
        char N = '\0';
        char termin = 'q' ;
        int er = 1;
        String termini;

        while( N != termin )
        {
        	System.out.println("POCKET CALCULATOR\n");
            System.out.println("Choose from the following options:\n");
            System.out.println("1. Addition ");
            System.out.println("2. Subtraction ");
            System.out.println("3. Multiplication ");
            System.out.println("4. Division ");
            System.out.println("5. Square Root\n ");
            do
            {
                er = 1 ;

                BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
                readinp = br.readLine();
                try
                {
                    func = Integer.parseInt(readinp);
                }
                catch(NumberFormatException oa)
                {
                    System.out.println("You entered an invalid character!");
                    er = 0;
                    func = 0;
                }
            } while(er == 0);

            switch(func)
            {
                case 1:
                    do
                    {
                        er=1;
                        System.out.print("\nPlease enter the first integer: ");
                            BufferedReader na1 = new BufferedReader(new InputStreamReader(System.in));
                            Snum1 = na1.readLine();
                            try
                            {
                                num1 = Double.parseDouble(Snum1);
                            }
                            catch(NumberFormatException oa)
                            {
                                System.out.println("You entered an invalid character!");
                                er = 0;
                            }
                    } while (er == 0);

                    do
                    {
                        er = 1;
                        System.out.print("\nPlease enter the second integer:");
                            BufferedReader na2 = new BufferedReader(new InputStreamReader(System.in));
                            Snum2 = na2.readLine();
                            try
                            {
                                num2 = Double.parseDouble(Snum2);
                            }
                            catch(NumberFormatException oa)
                            {
                                System.out.println("You entered an invalid character!");
                                er = 0;
                            }
                    } while (er == 0);

                    ans = num1 + num2;
                    System.out.println("\nAnswer:\n " + num1 + " + " + num2 + " = " + ans);
                break;

                case 2:
                    do
                    {
                        er = 1;
                        System.out.print("\nPlease enter the first integer: ");
                            BufferedReader ns1 = new BufferedReader(new InputStreamReader(System.in));
                            Snum1 = ns1.readLine();
                            try
                            {
                                num1 = Double.parseDouble(Snum1);
                            }
                            catch(NumberFormatException oa)
                            {
                                System.out.println("You entered an invalid character!");
                                er = 0;
                            }
                    } while(er == 0);

                    do
                    {
                        er = 1;
                        System.out.print("\nPlease enter the second integer: ");
                            BufferedReader ns2 = new BufferedReader(new InputStreamReader(System.in));
                            Snum2 = ns2.readLine();
                            try
                            {
                                num2 = Double.parseDouble(Snum2);
                            }
                            catch(NumberFormatException oa)
                            {
                                System.out.println("You entered an invalid character!");
                                er = 0;
                            }
                    } while (er == 0);

                    ans = num1 - num2;
                    System.out.println("\nAnswer\n" + num1 + " - " + num2 + " = " + ans);
                break;

                case 3:
                    do
                    {
                        er = 1;
                        System.out.print("\nPlease enter the first integer: ");
                            BufferedReader nm1 = new BufferedReader(new InputStreamReader(System.in));
                            Snum1 = nm1.readLine();
                            try
                            {
                                num1 = Double.parseDouble(Snum1);
                            }
                            catch(NumberFormatException oa)
                            {
                                System.out.println("You entered an invalid character!");
                                er = 0;
                            }
                    } while(er == 0);

                    do
                    {
                        er = 1;
                        System.out.print("\nPlease enter the second integer: ");
                            BufferedReader nm2 = new BufferedReader(new InputStreamReader(System.in));
                            Snum2 = nm2.readLine();
                            try
                            {
                                num2 = Double.parseDouble(Snum2);
                            }
                            catch(NumberFormatException oa)
                            {
                                System.out.println("You entered an invalid character!");
                                er = 0;
                            }
                    } while (er == 0);

                    ans = num1 * num2;
                    System.out.println("\nAnswer\n " + num1 + " * " + num2 + " = " + ans);
                break;

                case 4:
                    do
                    {
                        er = 1;
                        System.out.print("\nPlease enter the first integer: ");
                            BufferedReader nd1 = new BufferedReader(new InputStreamReader(System.in));
                            Snum1 = nd1.readLine();
                            try
                            {
                                num1 = Double.parseDouble(Snum1);
                            }
                            catch(NumberFormatException oa)
                            {
                                System.out.println("You entered an invalid character!");
                                er = 0;
                            }
                    } while(er == 0);

                    do
                    {
                        er = 1;
                        System.out.print("\nPlease enter the second integer: ");
                            BufferedReader nd2 = new BufferedReader(new InputStreamReader(System.in));
                            Snum2 = nd2.readLine();
                            try
                            {
                                num2 = Double.parseDouble(Snum2);
                            }
                            catch(NumberFormatException oa)
                            {
                                System.out.println("You entered an invalid character!");
                                er = 0;
                            }
                    } while (er == 0);

                    ans = num1 / num2;
                    System.out.println("\nAnswer\n" + num1 + " / " + num2 + " = " + ans);
                break;

                default:
             System.out.println("Invalid choice!  Try again!");
            }

            System.out.println("Enter N to terminate");
            BufferedReader ter = new BufferedReader(new InputStreamReader(System.in));
            termini = ter.readLine();
            try
            {
                termin = Character.parseChar(termini);
            }
                catch(NumberFormatException oa)
            {
                termin = N;
            }
            if( termin == 'N')
            {

            }

        }
    }
}

You can terminate a Java program immediately by executing
System.exit(0);
You can do this, for example, if the user types in 'N'.
If you have open files or network connections etc you should close those first, but in this case there's no such tidy-up needed, so keep it simple.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.