Urgent Help needed

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jaaz
    New Member
    • Oct 2007
    • 2

    #1

    Urgent Help needed

    Ive been given this assignment before the half term and i have to hand it in by monday basically its a program it has 5 erros and i cant find them could any1 help me with this pelase

    [code=java]
    Public class AddThree {
    import java.swing.JOpt ionPane;
    Public static void main (String args[ ] )
    String firstNumber, secondNumber, thirdNumber
    int num1, num2, num3, sum, product;
    double average;
    firstNumber = JOptionPane.sho wInputDialog (Enter first Integer:);
    secondNumber = JOptionPane.sho wInputDialog (Enter second Integer:" );
    thirdNumber = JOptionPane.sho wInputDialog (Enter second Integer: " );
    num1 = Integer.Parsein t(firstNumber) ;
    num2 = Integer.Parsein t(secondNumber) ;
    num3 = Integer.Parsein t(thirdNumber) ;
    Product = num1 * num2 * num3;
    average = sum / 3;
    JOptionPane.sho wMessagedialog( null,"The Sum is " + Sum + "\nthe product is JOptionpane.INF ORMATION_MESSAG E );
    system.exit(0);
    }

    }
    [/code]
    Last edited by JosAH; Oct 27 '07, 07:12 AM. Reason: added [code] ... [/code] tags
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Those are all compilation errors; the compiler does its utmost best to tell you:

    1) what line the error was found;
    2) what symbol caused the error;
    3) what was expected instead;
    4) the exact column position of the error.

    Read each compilation error one by one. Fix them one by one. You could even
    fix the first compilation error, recompile and repeat the process until all compilation
    errors are gone. I had a look at your code and most of the errors are simply typos,
    wrong upper/lower case, misplaced double quotes, forgotten semi colons etc.

    Just fix them and see if your program runs.

    kind regards,

    Jos

    Comment

    • jaaz
      New Member
      • Oct 2007
      • 2

      #3
      Thanks for the help i know this sound really dumb but cant you tell me in what lines i have got errors? if you help me with that it would be much apprecfiated.

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        Originally posted by jaaz
        Thanks for the help i know this sound really dumb but cant you tell me in what lines i have got errors? if you help me with that it would be much apprecfiated.
        But your compiler told you that already, line by line. Here are the first errors:

        1) 'public' has a lower case 'p', it's not 'Public'.
        2) the 'import' line should be the first line in the source file.

        You can do the rest yourself easily; just read what the compiler told you.

        kind regards,

        Jos

        Comment

        • dav3
          New Member
          • Nov 2006
          • 94

          #5
          Code:
          firstNumber = JOptionPane.showInputDialog (Enter first Integer:);
          secondNumber  = JOptionPane.showInputDialog (Enter second Integer:" );
          thirdNumber  = JOptionPane.showInputDialog (Enter second Integer:  " );

          just look at the colors. Colors are an easy way to spot thing such as improper use of quotes:)

          Comment

          • heat84
            New Member
            • Nov 2007
            • 118

            #6
            check the case of your keywords and also all imports must be outside the class. Java is case sensitive remember.

            Comment

            Working...