Sunday, October 4, 2015

Math and Random function in java

/** How to use Math and Random function in java.
 *   How to type casting in java
 */

package p2;
public class P2 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        double i=65.90;
        //positive round
        System.out.println(Math.ceil(i));
        //negetive round
        System.out.println(Math.floor(i));
        //random output with type casting
        System.out.println((int)(Math.random()*100));
      }
   }

No comments:

Post a Comment