Results 1 to 4 of 4
  1. #1
    Interista is offline Member
    Join Date
    Oct 2011
    Posts
    24
    Rep Power
    0

    Default I have a problem with a program to work out area of a circle - please help

    Java 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);
    		}
    }
    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 JOptionPane

    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?

  2. #2
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default Re: I have a problem with a program to work out area of a circle - please help

    Where did you define the method
    Java Code:
    DoubletoString(int x)
    and what is
    Java Code:
    OptionPane
    Check to make sure everything is spelled correctly.

  3. #3
    'Major is offline Member
    Join Date
    Oct 2011
    Posts
    1
    Rep Power
    0

    Default Re: I have a problem with a program to work out area of a circle - please help

    It should be
    Java Code:
    Double.toString(sum);
    and
    Java Code:
    JOptionPane.showMessageDialog(null, "Circle of radius " + b + " has area " + area);
    As the above poster said, make sure everything is spelled correctly.

  4. #4
    Interista is offline Member
    Join Date
    Oct 2011
    Posts
    24
    Rep Power
    0

    Default Re: I have a problem with a program to work out area of a circle - please help

    Thanks!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Similar Threads

  1. Perimeter of a Triangle and Circle Program
    By Zora in forum New To Java
    Replies: 7
    Last Post: 10-13-2011, 03:43 AM
  2. Another simple circle problem
    By Nap in forum New To Java
    Replies: 4
    Last Post: 08-08-2011, 05:28 PM
  3. Replies: 18
    Last Post: 05-22-2011, 10:00 PM
  4. Trying to write a circle program
    By paulmmj in forum New To Java
    Replies: 7
    Last Post: 10-12-2010, 06:06 PM
  5. java program help. find the radius of a circle
    By megironi in forum New To Java
    Replies: 1
    Last Post: 03-27-2009, 07:09 AM

Posting Permissions

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