![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Jan 2008
Posts: 54
Rep Power: 1
![]() |
Cannot Find Symbol
can someone please tell me what is wrong with this code? I really am a novice after reading so much and watching tutorials, and I am still not getting the most basic things.
import java.util.*;
import javax.swing.*;
import javax.swing.JOptionPane;
public class Main {
String user = JOptionPane.showInputDialog("Please enter a number: ");
int userPar = Integer.parseInt(user);
int num = 25;
int result = userPar * num;
String user2 = JOptionPane.showMessageDialog(result);
public static void main(String[] args) {
new Main();
}
} |
|
|
|
|
|
#2 |
|
Professional Programmer
|
Re: Cannot Find Symbol
String user2 = JOptionPane.showMessageDialog(result); JOptionPane.showMessageDialog() returns void, not a String. What are you trying to do here?
__________________
http://www.kevinherron.com/ |
|
|
|
|
|
#3 | |
|
Programmer
Join Date: Jan 2008
Posts: 54
Rep Power: 1
![]() |
Re: Cannot Find Symbol
Quote:
Thank you for replying. what I am trying to do is to get the number that the user enters in the first joptionpane window and multiply it with the int variable that is equal to 25 and then display the result in another window. I thought that I was doing that. Is their another way? |
|
|
|
|
|
|
#4 |
|
Professional Programmer
|
Re: Cannot Find Symbol
Just do this:
JOptionPane.showMessageDialog(result); Leave out the part where you assign it to the String user2.
__________________
http://www.kevinherron.com/ |
|
|
|
|
|
#5 |
|
Professional Programmer
|
Re: Cannot Find Symbol
Delete this.
__________________
http://www.kevinherron.com/ Last edited by andro; May 30th, 2008 at 12:39 PM. Reason: Double post. |
|
|
|
|
|
#6 |
|
Programmer
Join Date: Jan 2008
Posts: 54
Rep Power: 1
![]() |
Re: Cannot Find Symbol
Here is the code that I have now, and I am still receiving the cannot find symbol error. ??
import java.util.*;
import javax.swing.*;
import javax.swing.JOptionPane;
public class dif {
public dif() {
String user = JOptionPane.showInputDialog("Please enter a number: ");
int userPar = Integer.parseInt(user);
int num = 25;
int rand = (int)(10.0 * Math.random()) + 1;
int result = userPar * rand;
JOptionPane.showMessageDialog(result);
}
public static void main(String[] args) {
new dif();
}
} |
|
|
|
|
|
#7 |
|
Professional Programmer
|
Re: Cannot Find Symbol
__________________
http://www.kevinherron.com/ |
|
|
|
|
|
#8 |
|
Programmer
Join Date: Jan 2008
Posts: 54
Rep Power: 1
![]() |
Re: Cannot Find Symbol
Thank you, this worked. I just have to keep on practicing until it becomes second nature.
Thanks again. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Where to find a Dictionary/Thersarus API for .NET | bigguy | Visual Basic .NET | 3 | Mar 3rd, 2007 9:45 AM |
| Vector problem - find max, min and positions | codylee270 | C++ | 12 | Mar 20th, 2006 1:57 AM |
| Find a matching element in an XML file | Eleo | C# | 2 | Feb 16th, 2006 9:25 PM |
| inserting symbol into a string | Bernard | C | 26 | Aug 2nd, 2005 4:30 AM |
| Program that can find a patern | Anyways | C++ | 2 | Mar 22nd, 2005 3:27 AM |