• Log in or sign up for an account here: https://www.sythe.org/login

Java Math Kit V1 - Vinny

Jokerz

Forum Addict
Joined
Apr 24, 2008
Sythe Gold
0
Messages
610
Location
Australia
I made these in my spare time... I'm new to Java don't flame =)

--------------------

This will compute the area of a circle.

--------


Code:
/**
 * Compute the area of a circle
 * Copyright Vinny
 * Java Math Kit V1
 */

class Area {
    public static void main(String args[]) {
     double pi, r, a; //Calling pi, Radi, Area
    
     r = 10.8; //Change this Value to your Circles Radius
     pi = 3.1416; //Dont change this.
     a = pi * r *r;//Computing Area
    
     System.out.println("The Area of the circle is " + a);
    
    }
}
----------------------------------

This will compute the Hypotenuse of a triangle.

-------------


Code:
/**
 * This will calculate the Hypotenuse of a triangle
 *
 * Vinny
 * Java Math Kit V1
 */

class Hypotenuse {
    public static void main(String args[]) {
     double a = 3.0, b = 6.0; // Feel free to change these Values to match your Triangle.
    
     double c = Math.sqrt(a * a + b * b);
    
     System.out.println("The Hypotenuse of your Triangle is " + c);
    
    }
}
------------------------------------

This will compute the Speed of Light in Miles

---------


Code:
/**
 * Compute Distance light Travels in Miles.
 *
 * Copyright Vinny  
 * Java Math Kit V1.0
 */
class Light {
    public static void main(String args[]) {
        int lightspeed;
        long days;
        long seconds;
        long distance;
        
        //Speed of light travels at 18600 miles per second
        lightspeed = 186000;
        
        days = 1000; // Put how many days you need to compute here
        
        seconds = days * 24 * 60 * 60; //Dont change this
        
        distance = lightspeed * seconds;
        
        System.out.println("In " + days);
        System.out.println(" days light will travel ");
        System.out.println(distance + " miles.");
        
    }
    
}
----------------------

Any requests? Ask me
 
<3 n4n0
Discord Verified
Two Factor Authentication User
Community Participant
Spam Forum Participant
Sythe's 10th Anniversary
Sythe Awards 2011 Winner
I think pi is a constant built into java, but I could be wrong.

Now, just add input and it would be great!
 
hmm school is starting.

i wanna larn java so it can do my homework :D
 
<3 n4n0
Discord Verified
Two Factor Authentication User
Community Participant
Spam Forum Participant
Sythe's 10th Anniversary
Sythe Awards 2011 Winner
hmm school is starting.

i wanna larn java so it can do my homework :D

lol, i made a few java programs, in about 30 mins and finished loads of math hw with them that would have taken hours... and it was nice, since i love programming random shit i will use....


:D
 
I think pi is a constant built into java, but I could be wrong.

Now, just add input and it would be great!

It is:
Math.PI I believe.
 
Runescape Gamblingrunescape gambling
Back
Top