Project #4 and Calculator

Code

    /// Name: Lauren Baird
    /// Period: 7
    /// Program Name: Calculator
    /// File Name: p4.java
    /// Date Finished: 4/1/2016
    
    import java.util.Scanner;
    
    public class p4
    {
    	public static void main( String[] args )
    	{
    		Scanner keyboard = new Scanner(System.in);
    
    		double a, b, c;
    		String op;
            
            System.out.println();
    
    		do
    		{
    			System.out.print("> ");
    			a  = keyboard.nextDouble();
    			op = keyboard.next();
    			b  = keyboard.nextDouble();
    
    			if ( op.equals("+") )
    				c = a + b;
                
                else if ( op.equals("-") )
    				c = a - b;
                
                else if ( op.equals("*") )
    				c = a * b;
                
                else if ( op.equals("/") )
    				c = a / b;
                    
                else if ( op.equals("%") )
                    c = a % b;
                    
                else if ( op.equals("^") )
                {
                    c = 1;
                    
                    for ( int n = 0; n < b; n++ )
                    {
                        c = c * a;
                    }
                }
                
    			else
    			{
    				System.out.println("Undefined operator: '" + op + "' " );
                    c = 0;
    			}
                
                if ( a != 0 )
                {
                    System.out.println(c);
                    System.out.println();
                }
            
    		} while ( a != 0 );
            
            System.out.println( "Bye" );
            
    	}
    }
  
    

Picture of the output

Project #4