CalculatorProject

Code

import java.util.Scanner;

public class CalculatorProject
{
	public static void main( String[] args )
	{
		Scanner keyboard = new Scanner(System.in);

		double a, b, c=0;
		String op;

		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("^")) 
                {
                    Math.pow( a,b);
                }
            
                else if ( b==0 && op.equals("/") )
                {
                    System.out.println("Nope");
                    a = 0;
                }
    
                else
    			{
    				System.out.println("Undefined operator: '" + op + "'.");
    				c = 0;
    			}
    
    			System.out.println(c);
                System.out.println();
    
    		} while ( a != 0 );
        System.out.println( " Bye, now. " );
	}
}

CalculatorProject

Assignment project4