Assignment #107

Code

    
    ///Name: Cody Swain
    ///Period: 6
    ///Project Name: BabyCalculator2
    ///File Name: BabyCalculator2.java
    ///Date: 4/29/16
    
    
    
    import java.util.Scanner;

    public class BabyCalculator2
    {
        public static void main( String[] args )
        {
            
            Scanner kb = new Scanner(System.in);
            int a, b, c=0;
            String op;
            
            System.out.println("Simple Baby Calculator Program" );
            System.out.println("Enter a calculation. ");
            
            do
            {
                System.out.print("> ");
                a = kb.nextInt();
                op = kb.next();
                b = kb.nextInt();
                
                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 
                    System.out.println("Error");
                    
                System.out.println( a + op + b + " equals " + c );
            }
            while (a != 0);
        }
    }     
                
    



    

Picture of the output

Assignment 107