Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

>> REGISTER NOW TO START POSTING

# Thread: JOptionPane error in eclipse

1. ## JOptionPane error in eclipse

I am a beginner and I am I am practicing JOptionPane and trying to make this code work but the error message below keeps appearing. Please help me to sort it out.

The solution you gave me in January was very helpful. How can I say thanks

// Make calculations using three integers.

import javax.swing.JOptionPane;
public class Calculate3
{
public static void main( String[] args )
{
String firstNumber, secondNumber, thirdNumber;
String result;
int number1,number2,number3;
int sum, largest, smallest, product, average;
//read first number from user as string
firstNumber = JOptionPane.showInputDialog( “Enter first number: ” );
//read second number from user as a string
secondNumber = JOptionPane.showInputDialog( “Enter second number: ” );
//read third number from user as a string
thirdNumber = JOptionPane.showInputDialog( “Enter third number: ” );
//convert numbers from type String to type int
number1 = Integer.parseInt( firstNumber );
number2 = Integer.parseInt( secondNumber );
number3 = Integer.parseInt( thirdNumber );
//initialize largest and smallest
largest = number1;
smallest = number2;
//determine correct values
if ( number2 >= number1 )
{
largest = number2;
smallest = number1;
}
if ( number3 > largest )
largest = number3;
if ( number3 < smallest )
smallest = number3;
//perform calculations
sum = number1 + number2 + number3;
product = number1 * number2 * number3;
average = sum/3;
//print results
result = “For the numbers ” + number1 + "" + number2 + "" + number3 +
” \n ” + “The largest is ” + largest + ” \n ” +
“The smallest is ” + smallest + " \n" + “The sum is ” + sum +
"\n" + “The product is ” + product + "\n" +
“The average is ” + average + ” \n ;
//display the results
JOptionPane.showMessageDialog( null, result, “Calculate results”,
JOptionPane.INFORMATION_MESSAGE );
System.exit(0);
}
}

Error message

Exception in thread "main" java.lang.Error: Unresolved compilation problems:
The method showInputDialog(Object) in the type JOptionPane is not applicable for the arguments ()
Syntax error on tokens, delete these tokens
The method showInputDialog(Object) in the type JOptionPane is not applicable for the arguments ()
Syntax error on tokens, delete these tokens
The method showInputDialog(Object) in the type JOptionPane is not applicable for the arguments ()
Syntax error on tokens, delete these tokens
Syntax error on tokens, delete these tokens
Syntax error on tokens, delete these tokens
Syntax error on tokens, delete these tokens
Syntax error on tokens, delete these tokens
Syntax error on tokens, delete these tokens
Syntax error on tokens, delete these tokens
Syntax error on tokens, delete these tokens
n cannot be resolved
Syntax error on tokens, Expression expected instead

at Calculate3.main(Calculate3.java:14)

2. ## Re: JOptionPane error in eclipse

You could have said "Thanks" then.