Nim

Code

    ///Name: Tim Gibson
    ///Period: 6
    ///Project Name: Nim
    ///File Name: Nim.java
    ///Date Finished: 10/30/15
        
    import java.util.Scanner;
    
    public class Nim
    {
        public static void main ( String[] args )
        {
            Scanner keyboard = new Scanner(System.in);
            
            int a, b, c, d, n;
            String name1, name2, choice;
            n = 0;
            System.out.print( "Player 1, enter your name: " );
            name1 = keyboard.next();
           
            System.out.print( "Player 2, enter your name: " );
            name2 = keyboard.next();
            
            a = 3;
            b = 4;
            c = 5;
            
            
            
            while ( a + b + c != 0 )
            {
                System.out.println( "A: " + a + "\tB: " + b + "\tC: " + c );
                
                if ( ( n % 2 ) == 0 ) 
                    System.out.print( name1 );
                else
                    System.out.print( name2 );
                
                System.out.print( ", choose a pile: " );
                choice = keyboard.next();
                
                System.out.print( "How many to remove from pile " + choice + ": " );
                d = keyboard.nextInt();
                n = n + 1;
                if ( choice.equals("A") )
                    a = a - d;
                else if ( choice.equals("B") )
                    b = b - d;
                else if ( choice.equals("C") )
                    c = c - d;
                
            }
            
                if ( ( n % 2 ) == 0 )
                System.out.println( name1 + ", there are no counters left, so you win." );
                else 
                System.out.println( name2 + ", there are no counters left, so you win." );
            }
    }
        

Picture of the output

nim