I need to build a gui application for Nim. I started writing the code and need help. Will you help me write the Nim game?

import javax.swing.JOptionPane;
public class Nim {

public static void main( String args[] )
{
String firstNumber;
String secondNumber;
int number1;
int number2;
int sum;

firstNumber =
JOptionPane.showInputDialog( "Who should go first: 1. Human 2. Computer");

number1 = Integer.parseInt( firstNumber );
number2 = Integer.parseInt( secondNumber );

sum = number1 + number2;

JOptionPane.showMessageDialog(
null, "The sum is " + sum, "Rsults",
JOptionPane.PLAIN_MESSAGE );
System.exit( 0 );
}
}

Recommended Answers

Well...
You are getting your "firstNumber",
but you are NOT getting your "secondNumber".

Jump to Post

All 2 Replies

Member Avatar

Well...
You are getting your "firstNumber",
but you are NOT getting your "secondNumber".

friend you not input for second no in your program.

Be a part of the DaniWeb community

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