Alright I think I'm getting closer but now my program skips by my System.in feature so the radius is never enter and just runs to completion any help would be greatly appreciated

import java.util.Scanner;

public class Square
{
	static class Circle
	{
		float radius;
		
			public double CircleInfo()
			{
				Scanner in;
				in = new Scanner(System.in);
				System.out.println("Enter the radius");
			   radius = in.nextFloat;
			}
			
			public float radiusOut()
			{
				return radius;
			}
			
			public double diamOut()
			{
				return (radius * 2);
			}
			
			public double circumfOut()
			{
				return Math.PI * (radius * 2);
			}
			
			public double areaOut()
			{
				return Math.PI * Math.pow(radius, 2);
			}
	}
	
	public static void main(String[] args)
	{
		Circle testCircle;
		testCircle = new Circle();
		
		System.out.println("The radius is " + testCircle.radiusOut());
		System.out.println("The diameter is " + testCircle.diamOut());
		System.out.println("The circumference is " + testCircle.circumfOut());
		System.out.println("The area is " + testCircle.areaOut());
	}
}

Thanks

Dean

Recommended Answers

All 4 Replies

You never call your circleInfo method, so it doesn't get executed, so there's no user input.

Besides what JamesCherrill said, you'll probably have to put parenthesis after "in.nextFloat".

Does this even compile? Errors like parenthesis should fail to compile.

Do you understand that the entry point for your program is the main method?
It seems as if you ar expecting it too run through the code from top to bottom.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.