i am working on a program called myBalls. so far, heres what i have

import java.util.Scanner;

public class Penis {
    private int length;

    public Penis() {}

    public void setPenisLength(int l) {
        length = l;
    }

    public int penisLength() {
        return length;
    }
}

public class myBalls extends Penis{
    public static void main(String[] args) {
        Scanner reader = new Scanner(System.in);
        int numBalls = 2;
        int ballDiameter = 0;
        int ballCircumference = 0; //for now

        System.out.print("What is the length of the penis? ");
        setPenisLength(reader.nextInt());

        if (penisLength > 10) 
            numBalls = 3;
        else if (penisLength < 3)
            numBalls = 1;
        else if (penisLength <= 0) {
            numBalls = 0;
            System.out.pintln("You are a woman. Therefore, you have a vagina.");
        }

        Ball[] ball = new Ball[numBalls];

        ballDiameter = (penisLength / 3);
    }
}

So, i need help. how would i go about calculating the ball circumference. i think i would need pi or something, but how would i get the exact value of pi since it never ends, and what would i do with it?

any help would be greatly appreciated.

Edited 3 Years Ago by dicknballs: spelling

You can never obtain the exact value of PI, you are always bound to the limitations of memory and computation time.
Also a perfectly correct answer is not always needed in all circumstances.
Therefore it makes sense to determine how correct you want the answer to be and use an appropriate approximation for PI that achieves the level of correctness you want.
For simple programs like this one the PI constant defined in the Math class should be sufficient.

Use like this: Math.PI

Also from an OO-perspective myBalls extends Penis doesn't make sense, because what you are really doing is defining an IS A-relationship.
Concrete to this example it means that you defined that myBalls IS A Penis, which doesn't make sense.

Edited 3 Years Ago by mvmalderen

thank you.

so i would import the Math class

import java.util.Math;

and use Math.PI where i want to use the value of pi, but how exactly would I go about implementing this to find the ballCircumference? i assume finding the ballCircumference would be the same as finding the circumference of a circle, but i failed geometry so i dont know what to do.

cheers

so i would import the Math class

No need to import it, it's in the java.lang package, meaning that you can use all the classes in that package without having to import them explicitly.

and use Math.PI where i want to use the value of pi

Yes.

how exactly would I go about implementing this to find the ballCircumference? i assume finding the ballCircumference would be the same as finding the circumference of a circle

That should work.

This article has been dead for over six months. Start a new discussion instead.