Adblock breaks this site

Java Math Kit V1 - Vinny

Discussion in 'Programming General' started by Jokerz, Jun 13, 2008.

  1. Jokerz

    Jokerz Forum Addict

    Joined:
    Apr 24, 2008
    Posts:
    610
    Referrals:
    0
    Sythe Gold:
    0
    Java Math Kit V1 - Vinny

    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
     
  2. greatfate

    greatfate Guest

    Referrals:
    0
    Java Math Kit V1 - Vinny

    Thank you Very much for these.
     
  3. SuF

    SuF Legend
    Pirate Retired Global Moderator

    Joined:
    Jan 21, 2007
    Posts:
    14,212
    Referrals:
    28
    Sythe Gold:
    1,234
    Discord Unique ID:
    203283096668340224
    <3 n4n0 Two Factor Authentication User Community Participant Spam Forum Participant Sythe's 10th Anniversary
    Java Math Kit V1 - Vinny

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

    Now, just add input and it would be great!
     
  4. 0017513060

    0017513060 Forum Addict

    Joined:
    Mar 9, 2007
    Posts:
    413
    Referrals:
    0
    Sythe Gold:
    0
    Java Math Kit V1 - Vinny

    hmm school is starting.

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

    SuF Legend
    Pirate Retired Global Moderator

    Joined:
    Jan 21, 2007
    Posts:
    14,212
    Referrals:
    28
    Sythe Gold:
    1,234
    Discord Unique ID:
    203283096668340224
    <3 n4n0 Two Factor Authentication User Community Participant Spam Forum Participant Sythe's 10th Anniversary
    Java Math Kit V1 - Vinny

    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
     
  6. bkatz

    bkatz Forum Addict
    Banned

    Joined:
    Apr 21, 2005
    Posts:
    402
    Referrals:
    0
    Sythe Gold:
    0
    Java Math Kit V1 - Vinny

    It is:
    Math.PI I believe.
     
< Vb 2008 or 2005 dont care, Question | How do I change the look of a window? >


 
 
Adblock breaks this site