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


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: JOptionPane error in eclipse

  1. #1
    Junior Member
    Join Date
    Jan 2013
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 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. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: JOptionPane error in eclipse

    You could have said "Thanks" then.

    Please post your code, properly indented, in code tags.

    Your open and close quotes are the wrong kind of quotes. Be sure that whatever editor you're using is using the plain text version of the quote, ' " ', character. If you need help setting your editor to do that, let us know which one you're using.

  3. #3
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: JOptionPane error in eclipse

    The method showInputDialog(Object) in the type JOptionPane is not applicable for the arguments ()
    Check the documentation for use of the method

    Perhaps errors like this are the result of a missing or extra brace/bracket/semicolon/quote.... I would check all of those
    Please use code tags when posting code to the forum. Assistance can be found in the Announcements thread

Similar Threads

  1. [SOLVED] Logic error in Math.pow(a,b) using JOptionPane
    By JAKATAK in forum What's Wrong With My Code?
    Replies: 7
    Last Post: February 8th, 2013, 01:18 AM
  2. Error message when using JOptionPane
    By runkerr in forum What's Wrong With My Code?
    Replies: 7
    Last Post: February 5th, 2013, 12:17 PM
  3. Error in Eclipse, Norm redirected me here.
    By SilentNite17 in forum Java IDEs
    Replies: 3
    Last Post: February 14th, 2012, 09:48 PM
  4. Error Running Java in Eclipse
    By steadyonabix in forum Java IDEs
    Replies: 1
    Last Post: September 3rd, 2011, 10:28 PM
  5. Error when opening eclipse
    By BlackJavaCoder in forum Java IDEs
    Replies: 4
    Last Post: September 3rd, 2011, 07:57 AM