import javax.swing.JOptionPane

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hairul
    New Member
    • Nov 2011
    • 1

    import javax.swing.JOptionPane

    Dear friend,

    I hope u can help me figuring out this code.I'm very new in this java environment.


    import javax.swing.JOp tionPane;

    public class GreatestNumber {

    public static void main (String[]args){

    int[]num=new int[10];
    int counter;
    int max=0;
    int totalnumber=3;


    for(counter=0;c ounter<totalnum ber;counter++){

    num[counter]=Integer.parseI nt
    (JOptionPane.sh owInputDialog(" Enter numbers until" + totalnumber + "numbers are entered"));

    If ((counter==0)|| (num[counter]>max))
    max=num[counter];

    }
    JOptionPane.sho wMessageDialog( null,"The number with the greatest value is " + max);

    }

    }


    the compiler returned this error.


    GreatestNumber. java:18: error: ')' expected
    If ((counter==0)
    ^
    GreatestNumber. java:19: error: not a statement
    (num[counter]>max)


    more, I have to answer these 2 questions:

    1)compute the smallest number and display it
    2)compute the average for 3 numbers and display it.


    i am very honored if you can help me with these questions..Than k u so much.
  • AbrahamNkomo
    New Member
    • Aug 2010
    • 4

    #2
    l think you need check the spelling of java keyword that is "if" , it must have small letter "i" not capital letter .l think this help .

    Comment

    Working...