Results 1 to 12 of 12
Thread: Problems with a basic project
- 04-08-2011, 02:57 AM #1
Member
- Join Date
- Apr 2011
- Posts
- 9
- Rep Power
- 0
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 02:59 AM.
-
It does more than nothing, it shows a compilation error and does not compile. Please post the error message.
Edit: disregarded.
- 04-08-2011, 03:02 AM #3
Member
- Join Date
- Apr 2011
- Posts
- 9
- Rep Power
- 0
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.
-
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!
-
- 04-08-2011, 03:20 AM #6
Member
- Join Date
- Apr 2011
- Posts
- 9
- Rep Power
- 0
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. ^_^;And the errors are likely telling exactly what is wrong.
-
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,
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.Java Code:int Result = 0
- 04-08-2011, 04:19 AM #8
Member
- Join Date
- Apr 2011
- Posts
- 2
- Rep Power
- 0
Your braces and ur semicolons.
This indicates classes methods and ends of statements
- 04-08-2011, 05:42 AM #9
Senior Member
- Join Date
- Mar 2011
- Posts
- 144
- Rep Power
- 0
Should be this
Java Code:int Result=0;
Java Code:public class Multiply{
- 04-08-2011, 05:58 AM #10
Member
- Join Date
- Apr 2011
- Posts
- 9
- Rep Power
- 0
Wow, I feel really silly right now.
Thanks for the help. :)
-
- 04-08-2011, 06:24 AM #12
Senior Member
- Join Date
- Mar 2011
- Posts
- 144
- Rep Power
- 0
Similar Threads
-
Adding a project to an existing project
By Seijuro in forum NetBeansReplies: 4Last Post: 08-08-2010, 10:15 AM -
ASAP PLZ- Having problems with basic pattern input/output
By ZetaPunk in forum New To JavaReplies: 3Last Post: 09-22-2009, 05:16 AM -
open existing project project ..
By itaipee in forum EclipseReplies: 1Last Post: 12-28-2008, 08:12 PM -
HelpNeeded!!!Facing Problems in a Project
By goodwillwins in forum AWT / SwingReplies: 2Last Post: 08-08-2008, 06:44 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks