Results 1 to 12 of 12
  1. #1
    Goff256 is offline Member
    Join Date
    Apr 2011
    Posts
    9
    Rep Power
    0

    Unhappy Problems with a basic project

    I'm supposed to make something that takes two integers and multiplies them. So far, I have:

    import javax.swing.*;
    public class Multiply {
    public static void main(String[] args) {
    int firstVariable=0 ;
    int secondVariable=0 ;
    int Result=0
    firstVariable=Integer.parseInt(JOptionPane.showInp utDialog("Enter first integer"));
    secondVariable=Integer.parseInt(JOptionPane.showIn putDialog("Enter second integer"));
    Result = firstVariable*secondVariable;
    JOptionPane.showMessageDialog(null, "Multiplication: "+Result);

    }
    }

    And it does nothing.
    Last edited by Goff256; 04-08-2011 at 03:59 AM.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    It does more than nothing, it shows a compilation error and does not compile. Please post the error message.

    Edit: disregarded.

  3. #3
    Goff256 is offline Member
    Join Date
    Apr 2011
    Posts
    9
    Rep Power
    0

    Default I really thought I had it this time

    But for some reason I can't get it.

    Multiply-Java.java:2: '{' expected
    public class Multiply
    ^
    Multiply-Java.java:6: ';' expected
    int Result=0
    ^
    2 errors

    ----jGRASP wedge2: exit code for process is 1.
    ----jGRASP: operation complete.

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by Goff256 View Post
    But for some reason I can't get it.

    Multiply-Java.java:2: '{' expected
    public class Multiply
    ^
    Multiply-Java.java:6: ';' expected
    int Result=0
    ^
    2 errors

    ----jGRASP wedge2: exit code for process is 1.
    ----jGRASP: operation complete.
    Please post your latest code, but if you do, please use code tags so that your code will retain its formatting and thus will be readable -- after all, your goal is to get as many people to read your post and understand your code as possible, right?

    To do this, highlight your pasted code (please be sure that it is already formatted when you paste it into the forum; the code tags don't magically format unformatted code) and then press the code button, and your code will have tags.

    Another way to do this is to manually place the tags into your code by placing the tag [code] above your pasted code and the tag [/code] below your pasted code like so:

    Java Code:
    [code]
      // your code goes here
      // notice how the top and bottom tags are different
    [/code]

    Good luck!

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by Goff256 View Post
    Multiply-Java.java:2: '{' expected
    public class Multiply
    ^
    Multiply-Java.java:6: ';' expected
    int Result=0
    ^
    2 errors

    ----jGRASP wedge2: exit code for process is 1.
    ----jGRASP: operation complete.
    And the errors are likely telling exactly what is wrong.

  6. #6
    Goff256 is offline Member
    Join Date
    Apr 2011
    Posts
    9
    Rep Power
    0

    Default

    Java Code:
    import javax.swing.*;
    public class Multiply
    public static void main(String[] args) {
    int firstVariable=0 ;
    int secondVariable=0 ;
    int Result=0
    firstVariable=Integer.parseInt(JOptionPane.showInputDialog("Enter first integer"));
    secondVariable=Integer.parseInt(JOptionPane.showInputDialog("Enter second integer"));
    Result = firstVariable*secondVariable;
    JOptionPane.showMessageDialog(null, "Multiplication: "+Result);
    
    	}
    }
    And the errors are likely telling exactly what is wrong.
    That would be awesome if I understood anything about the errors. I'm just learning this. ^_^;

  7. #7
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by Goff256 View Post
    Java Code:
    import javax.swing.*;
    public class Multiply
    public static void main(String[] args) {
    int firstVariable=0 ;
    int secondVariable=0 ;
    int Result=0
    firstVariable=Integer.parseInt(JOptionPane.showInputDialog("Enter first integer"));
    secondVariable=Integer.parseInt(JOptionPane.showInputDialog("Enter second integer"));
    Result = firstVariable*secondVariable;
    JOptionPane.showMessageDialog(null, "Multiplication: "+Result);
    
    	}
    }


    That would be awesome if I understood anything about the errors. I'm just learning this. ^_^;
    OK, let's look at the messages:


    Multiply-Java.java:2: '{' expected
    public class Multiply
    ^

    Check your line above that corresponds with this error message. The message is saying that '{' is expected but is missing. Now look at your text book to see how classes should be coded, and see that in fact you are missing a '{'. Again, the error message is unambiguous.

    Next:
    Multiply-Java.java:6: ';' expected
    int Result=0

    Look at your line,
    Java Code:
    int Result = 0
    and read the error message. Try to figure this one out yourself, and let me know your thoughts. I'm betting you can solve it if you give it thought.

  8. #8
    Jervhen is offline Member
    Join Date
    Apr 2011
    Posts
    2
    Rep Power
    0

    Default

    Your braces and ur semicolons.

    This indicates classes methods and ends of statements

  9. #9
    Ryan10 is offline Senior Member
    Join Date
    Mar 2011
    Posts
    144
    Rep Power
    0

    Default

    Should be this

    Java Code:
    int Result=0;
    Java Code:
    public class Multiply{

  10. #10
    Goff256 is offline Member
    Join Date
    Apr 2011
    Posts
    9
    Rep Power
    0

    Default

    Wow, I feel really silly right now.

    Thanks for the help. :)

  11. #11
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by Goff256 View Post
    Wow, I feel really silly right now.

    Thanks for the help. :)
    Please don't feel silly, but know that our goal is to get you to read those "cryptic" error messages and try to make sense out of them. Once you start doing that, you will move along with your Java education much faster.

  12. #12
    Ryan10 is offline Senior Member
    Join Date
    Mar 2011
    Posts
    144
    Rep Power
    0

    Default

    Change to [SOLVED] if you believe you are finished with this task..uinder the thread tools in the upper right of the page

Similar Threads

  1. Adding a project to an existing project
    By Seijuro in forum NetBeans
    Replies: 4
    Last Post: 08-08-2010, 11:15 AM
  2. Replies: 3
    Last Post: 09-22-2009, 06:16 AM
  3. open existing project project ..
    By itaipee in forum Eclipse
    Replies: 1
    Last Post: 12-28-2008, 09:12 PM
  4. HelpNeeded!!!Facing Problems in a Project
    By goodwillwins in forum AWT / Swing
    Replies: 2
    Last Post: 08-08-2008, 07:44 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •