Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: cannot find symbol variable radius?

  1. #1
    Junior Member
    Join Date
    Sep 2009
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question cannot find symbol variable radius?

    public class solvearea{
     
        public static double calculatearea(){
     
            double methodArea = (radius*2)*3.1416;
            return methodArea;
    }
        public static void main (String[]args){
            System.out.println("Enter shape: ");
            System.out.println("1.Circle, 2.Rectangle, 3.Square, 4.Triangle.");
            System.out.println("Enter number: ");
            double choice = Keyboard.readDouble();
            //circle
            if(choice == 1){
                System.out.println("You have chosen circle... ");
                System.out.println("Enter radius");
                double radius = Keyboard.readDouble();
                double theArea = calculatearea();
                System.out.println(theArea);
       }
    }
    help pls....


  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,895
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: cannot find symbol variable radius?

    simple, you left out the parameter radius from the computearea method

    public static double computearea(double radius)

  3. #3
    Junior Member
    Join Date
    Sep 2009
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: cannot find symbol variable radius?

    uhm...where do i put that code?

    o tried " public static double calculatearea(double radius){ "
    doesnt work...
    it says cannot be applied to

  4. #4
    Java kindergarten chronoz13's Avatar
    Join Date
    Mar 2009
    Location
    Philippines
    Posts
    659
    Thanks
    177
    Thanked 30 Times in 28 Posts

    Red face Re: cannot find symbol variable radius?

    i copied your first code..
    theres no variable 'radius' and
    theres no 'Keyboard' class

  5. #5
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,895
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: cannot find symbol variable radius?

    changes are in bold

    [b]import java.util.Scanner;[/b]
     
    public class solvearea{
     
    	public static double calculatearea([b]double radius[/b])
    	{
     
    		double methodArea = (radius * 2) * 3.1416;
    		return methodArea;
    	}
     
    	public static void main(String[] args)
    	{
    		[b]Scanner keyboard = new Scanner(System.in);[/b]
    		System.out.println("Enter shape: ");
    		System.out.println("1.Circle, 2.Rectangle, 3.Square, 4.Triangle.");
    		System.out.println("Enter number: ");
    		double choice = [b]k[/b]eyboard.readDouble();
    		// circle
    		if (choice == 1)
    		{
    			System.out.println("You have chosen circle... ");
    			System.out.println("Enter radius");
    			double radius = [b]k[/b]eyboard.readDouble();
    			double theArea = calculatearea([b]radius[/b]);
    			System.out.println(theArea);
    		}
    	}
    }
    Last edited by helloworld922; October 4th, 2009 at 10:42 AM.

Similar Threads

  1. SIGAR to find CPU info-problem
    By ttsdinesh in forum Exceptions
    Replies: 7
    Last Post: October 4th, 2009, 10:33 AM
  2. could not find the main class
    By Tisofa in forum Object Oriented Programming
    Replies: 1
    Last Post: September 27th, 2009, 02:58 AM
  3. Replies: 5
    Last Post: September 19th, 2009, 06:48 AM
  4. [SOLVED] find the position of the field separator in the String---need help ASAP
    By rajesh.mv in forum Java Theory & Questions
    Replies: 6
    Last Post: August 17th, 2009, 10:33 AM
  5. [SOLVED] How to a set java class path?
    By captjade in forum Java Theory & Questions
    Replies: 1
    Last Post: March 10th, 2009, 06:40 AM