Computing.Net > Forums > Programming > simple java help

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

simple java help

Reply to Message Icon

Name: Dark29delx
Date: September 27, 2005 at 18:43:57 Pacific
OS: Windows XP Pro
CPU/Ram: 2.6Ghz HT - 1536MB
Comment:

Hi, I need help with this excersise for java. I don't know how to do this very well but it says this, and it should be pretty easy to do, but I need to see how it's done to understand it, thanx and plz help.

Implement a class Circle that has methods getArea() and getPermeter(). In the constructor, supply the radius of the circle.

Dell Dimension 4600
Intel Pentium 4 2.6Ghz w/ HT and 800Mhz fbs.
1.5GB DUAL CHANNEL DDR SDRAM RAM 400mhz
ATI Radeon 9800 PRO 128MB DDR
120GB ATA 7200HD
Sound Blaster Live! 5.1
4.1 Al



Sponsored Link
Ads by Google

Response Number 1
Name: Dark29delx
Date: September 27, 2005 at 21:42:22 Pacific
Reply:

Ok I made the test file correctly.
public class CircleTest
{
public static void main(String[] args)
{

Circle myCircle = new Circle(10);
System.out.println(myCircle.getArea());
}
}

however my other one isnt lol

public class Circle
{
public Circle(10)
{
radii = 10;
}
public void formula(double formula)
{
formula = 3.14 * radii * radii;
}
public double getArea()
{
return getArea();

}
}

Dell Dimension 4600
Intel Pentium 4 2.6Ghz w/ HT and 800Mhz fbs.
1.5GB DUAL CHANNEL DDR SDRAM RAM 400mhz
ATI Radeon 9800 PRO 128MB DDR
120GB ATA 7200HD
Sound Blaster Live! 5.1
4.1 Al


0

Response Number 2
Name: HHitman1
Date: October 18, 2005 at 12:53:23 Pacific
Reply:

to make the Circle class
assuming radius is a property that the class contains:

public class Circle {
//Initialize the properties ie radius
int radius;

//Constructors
Circle(int radius) {
this.radius = radius;
}

public double getArea() {
return radius * radius * 3.14;
}

//Perimeter aka Circumference
public double getPerimeter() {
//With Circumference bein 2*pi*r
return 2 * 3.14 * radius;
}
}
this should be correct although im not 100 percent sure on the problem specs.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: simple java help

simple java help www.computing.net/answers/programming/simple-java-help/14579.html

Simple java help www.computing.net/answers/programming/simple-java-help/13416.html

Simple Java Question www.computing.net/answers/programming/simple-java-question/11523.html