Support Forums

Full Version: Sector Area
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Lately I have decided that I would get back into the swing of things with Java. So as a first small project I made this. Nothing fancy, just something to get me going again.

Code:
import java.util.Scanner;
public class SectorArea {

    public static void main(String[] args) {
        double radius, degrees, AreaOfSector; //Declarations for later.
        Scanner scan = new Scanner(System.in); //Creating a scanner
        System.out.println("Enter the radius of the circle.");
        radius = scan.nextDouble(); //Setting radius equal to userinputed value.
        System.out.println("Now please enter the number of degrees of the sector.");
        degrees = scan.nextDouble();
        AreaOfSector = ((Math.pow(radius, 2) * 3.14) * degrees) / 360; //The actual math part. :D
        System.out.println("The area of your sector is equal to: " + AreaOfSector);
    }
}
By reading this though:
Title Wrote:Sector Area

And this:
Thread Description Wrote:Lately I have decided that I would get back into the swing of things with Java. So as a first small project I made this. Nothing fancy, just something to get me going again.

It doesn't tell people a whole lot about what it is supposed to do unless they take time to read through the code to get a general understanding

From the looks of it though it measures the area of a certain section of a circle from a tangent?
(02-01-2012, 03:55 PM)AceInfinity Wrote: [ -> ]By reading this though:

And this:
Thread Description Wrote:Lately I have decided that I would get back into the swing of things with Java. So as a first small project I made this. Nothing fancy, just something to get me going again.

It doesn't tell people a whole lot about what it is supposed to do unless they take time to read through the code to get a general understanding

From the looks of it though it measures the area of a certain section of a circle from a tangent?

Ow I guess I could have included info, but I assume most people know it lol.

[Image: image27.gif]

It is finding the area of the "pie slice" shape within the circle. You can also modify my code around, to do it if you are missing some of the other elements in the formula.



I don't program in Java, but it's still easy to read code in general lol. I assumed as much there, but instead of 3.14 surely there's a more accurate calculation of that number which can be used?
(02-01-2012, 05:16 PM)AceInfinity Wrote: [ -> ]I don't program in Java, but it's still easy to read code in general lol. I assumed as much there, but instead of 3.14 surely there's a more accurate calculation of that number which can be used?

Pi is an irrational number and a constant which means it will never stop. The most that has been worked out is 3.1415.. and a few hundred thousand more numbers.

[Image: 200px-PI.svg.png]

http://oeis.org/A000796
(02-01-2012, 05:20 PM)Sam Wrote: [ -> ]Pi is an irrational number and a constant which means it will never stop. The most that has been worked out is 3.1415.. and a few hundred thousand more numbers.

[Image: 200px-PI.svg.png]

http://oeis.org/A000796

I know what it is, I was saying though that there are better ways to use it than to round to ONLY 2 decimal places though. And some languages also include PI as a function which uses a high decimal place I believe.
I mean you could expand out a bit more (pi), to get a more precise answer, but for school and what not they ask us to round the the first decimal place.
Whats it do before i go running it!
Smile
(02-04-2012, 10:35 PM)Denny Crane Wrote: [ -> ]Whats it do before i go running it!
Smile

Read through the posts and you'll see Smile
Ah i see, this could have helped back in my last damn exam. sigh.
Pages: 1 2