Results 1 to 4 of 4
- 10-26-2011, 04:01 PM #1
Member
- Join Date
- Oct 2011
- Posts
- 24
- Rep Power
- 0
I have a problem with a program to work out area of a circle - please help
I need to convert the string the user enters into a double, do the sum, and put the sum back into a string to print out using JOptionPaneJava Code:import javax.swing.JOptionPane; public class area { public static void main (String[] args) { String a, area; double b, sum; a=JOptionPane.showInputDialog(null, "Enter circle radius:"); b=Double.parseDouble(a); sum = b*b*3.1416; area = DoubletoString(sum); OptionPane.showMessageDialog(null, "Circle of radius " + b + " has area " + area); System.exit(0); } }
It is telling me...
area.java:15: error: cannot find symbol
area = DoubletoString(sum);
and has an arrow under the D
then it tells me
area.java:17:error: cannot find symbol
OptionPane.showMessageDialog(null, "Circle of radius " + b + " has area" + area);
and has an arrow under the )
What have I done wrong?
- 10-26-2011, 04:32 PM #2
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
Re: I have a problem with a program to work out area of a circle - please help
Where did you define the method
and what isJava Code:DoubletoString(int x)
Check to make sure everything is spelled correctly.Java Code:OptionPane
- 10-26-2011, 05:12 PM #3
Member
- Join Date
- Oct 2011
- Posts
- 1
- Rep Power
- 0
Re: I have a problem with a program to work out area of a circle - please help
It should be
andJava Code:Double.toString(sum);
As the above poster said, make sure everything is spelled correctly.Java Code:JOptionPane.showMessageDialog(null, "Circle of radius " + b + " has area " + area);
- 10-26-2011, 05:20 PM #4
Member
- Join Date
- Oct 2011
- Posts
- 24
- Rep Power
- 0
Similar Threads
-
Perimeter of a Triangle and Circle Program
By Zora in forum New To JavaReplies: 7Last Post: 10-13-2011, 03:43 AM -
Another simple circle problem
By Nap in forum New To JavaReplies: 4Last Post: 08-08-2011, 05:28 PM -
Odd results from simple circle area/circumference calculation
By cottoneyemoe in forum New To JavaReplies: 18Last Post: 05-22-2011, 10:00 PM -
Trying to write a circle program
By paulmmj in forum New To JavaReplies: 7Last Post: 10-12-2010, 06:06 PM -
java program help. find the radius of a circle
By megironi in forum New To JavaReplies: 1Last Post: 03-27-2009, 07:09 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks