Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Short Java error

  1. Sep 17, 2005 #1
    What does an " ')' expected " error signify? How did I not use parentheses correctly?

    The error is in this line:

    System.out.println(num1 + " " + num2 + " " + num 3 + " " + num4 + " " + num5) ;

    What possible mistake can there be in parentheses?
     
  2. jcsd
  3. Sep 17, 2005 #2

    Hurkyl

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    Such errors can often be symptoms of other syntactic mistakes. An error on a previous line could do it, but I bet it's really that nifty space you have between `num' and `3'.
     
  4. Sep 17, 2005 #3
    The program is, as follows:
    -----------------------------------
    import javax.swing.JOptionPane ;

    public class DigitSpacer {

    public static void main(String args[]) {

    String input;
    int num0;
    int num1;
    int num2;
    int num3;
    int num4;
    int num5;

    input = JOptionPane.showInputDialog("What is the number?");

    num0 = Int.parseInt(input);

    num1 = Math.floor(num0 / 10000);

    num2 = Math.floor((num0 - 10000 * num1) / 1000);

    num3 = Math.floor((num0 - 10000 * num1 - 1000 * num2 ) / 100);

    num4 = Math.floor( (num0 - 10000 * num1 - 1000 * num2 - 100 * num3 ) / 10);

    num5 = num0 - 10000 * num1 - 1000 * num2 - 100 * num3 - 10 * num4 ;

    System.out.println( num1 + " " + num2 + " " + num 3 + " " + num4 + " " + num5 );

    System.exit(0);

    }//main
    }//DigitSpacer
    --------------------------------------------------------
    The only error is that "')' expected error" for some reason
    regarding the line with System.out.println

    *In another trial, I deleted the spaces, but I keep getting the same error!
     
  5. Sep 17, 2005 #4

    Hurkyl

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    I still think it's the space between `num' and `3'.
     
  6. Sep 17, 2005 #5
    Ohhh--->that space?

    How can I fix that? :redface:
     
  7. Sep 17, 2005 #6

    Hurkyl

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    Well, you place your cursor just to the left of the three (and thus to the right of the offending space), and press your backspace key! :biggrin:
     
  8. Sep 17, 2005 #7
    Many thanks! :smile:

    Indeed that was the error!
     
    Last edited: Sep 17, 2005
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?



Similar Discussions: Short Java error
  1. Short Question (Replies: 2)

  2. Java Help (Replies: 7)

  3. Java help (Replies: 15)

  4. Java q (Replies: 3)

  5. Java problem. (Replies: 4)

Loading...