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)