Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old May 29th, 2008, 11:22 AM   #1
kewlgeye
Programmer
 
Join Date: Jan 2008
Posts: 54
Rep Power: 1 kewlgeye is on a distinguished road
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();
    }

}
kewlgeye is offline   Reply With Quote
Old May 29th, 2008, 9:29 PM   #2
andro
Professional Programmer
 
Join Date: Oct 2005
Location: California
Posts: 311
Rep Power: 3 andro is on a distinguished road
Send a message via AIM to andro
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/
andro is offline   Reply With Quote
Old May 30th, 2008, 11:25 AM   #3
kewlgeye
Programmer
 
Join Date: Jan 2008
Posts: 54
Rep Power: 1 kewlgeye is on a distinguished road
Re: Cannot Find Symbol

Quote:
Originally Posted by andro View Post
String user2 = JOptionPane.showMessageDialog(result);

JOptionPane.showMessageDialog() returns void, not a String. What are you trying to do here?

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?
kewlgeye is offline   Reply With Quote
Old May 30th, 2008, 11:38 AM   #4
andro
Professional Programmer
 
Join Date: Oct 2005
Location: California
Posts: 311
Rep Power: 3 andro is on a distinguished road
Send a message via AIM to andro
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/
andro is offline   Reply With Quote
Old May 30th, 2008, 11:38 AM   #5
andro
Professional Programmer
 
Join Date: Oct 2005
Location: California
Posts: 311
Rep Power: 3 andro is on a distinguished road
Send a message via AIM to andro
Re: Cannot Find Symbol

Delete this.
__________________
http://www.kevinherron.com/

Last edited by andro; May 30th, 2008 at 11:39 AM. Reason: Double post.
andro is offline   Reply With Quote
Old May 30th, 2008, 2:05 PM   #6
kewlgeye
Programmer
 
Join Date: Jan 2008
Posts: 54
Rep Power: 1 kewlgeye is on a distinguished road
Re: Cannot Find Symbol

Quote:
Originally Posted by andro View Post
Delete this.
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();
    }

}
kewlgeye is offline   Reply With Quote
Old May 30th, 2008, 3:03 PM   #7
andro
Professional Programmer
 
Join Date: Oct 2005
Location: California
Posts: 311
Rep Power: 3 andro is on a distinguished road
Send a message via AIM to andro
Re: Cannot Find Symbol

http://java.sun.com/j2se/1.5.0/docs/...a.lang.Object)

JOptionPane.showMessageDialog(null, result);
__________________
http://www.kevinherron.com/
andro is offline   Reply With Quote
Old Jun 2nd, 2008, 1:11 AM   #8
kewlgeye
Programmer
 
Join Date: Jan 2008
Posts: 54
Rep Power: 1 kewlgeye is on a distinguished road
Re: Cannot Find Symbol

Thank you, this worked. I just have to keep on practicing until it becomes second nature.

Thanks again.
kewlgeye is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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 8:45 AM
Vector problem - find max, min and positions codylee270 C++ 12 Mar 20th, 2006 12:57 AM
Find a matching element in an XML file Eleo C# 2 Feb 16th, 2006 8:25 PM
inserting symbol into a string Bernard C 26 Aug 2nd, 2005 3:30 AM
Program that can find a patern Anyways C++ 2 Mar 22nd, 2005 2:27 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 7:04 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC