Results 1 to 6 of 6

Thread: Java ME SDK 3.0 Math Class

  1. #1
    Join Date
    Apr 2010
    Posts
    77

    Java ME SDK 3.0 Math Class

    We propose to write a JAVA program PrixLot1.java who plays the role of playmaker and the execution of this program you will take the role of the player. The program Prixlot1must set the price of the lot drawing a random integer between 1 and 1000 and dialogue with the player during the game. But i did not find Math Class in Java ME SDK 3.0. Any idea?

  2. #2
    Join Date
    Feb 2008
    Posts
    1,852

    Re: Java ME SDK 3.0 Math Class

    To choose a random number we will use the random class Math , which returns a real (double) randomly and uniformly in the interval [0 1]
    example
    Code:
    double x;
          x = Math.random ();
    example of running the program PrixLot1

    Code:
    Eudoxus% java PrixLot1
    The goal is to seek a price between 0 and 1000
    Enter a price: 566
    Too
    Enter a price: 400
    Too
    Enter a price: 150
    Too small
    Enter a price: 200
    Too small
    Enter a price: 214
    BRAVO You have won five trials
    Eudoxus%

  3. #3
    Join Date
    May 2008
    Posts
    2,297

    Re: Java ME SDK 3.0 Math Class

    Here is the description of different "tools" that can allow you to make mathematical calculations. The first two classes are part of the standard JDK, the latter is an API of Jakarta Commons project.Math (package java.lang): The Math class contains a set of static methods to do basic numerical operations (logarithms, exponential or trigonometric functions). Unlike the class StrictMath, different implementations of the same method does not give the same result "bitwise". We can nevertheless note that, generally, implementations of the methods of the Math class to call methods StrictMath. If accuracy is not paramount, you may prefer to StrictMath Math for performance reasons.

  4. #4
    Join Date
    May 2008
    Posts
    2,389

    Re: Java ME SDK 3.0 Math Class

    # StrictMath (package java.lang): StrictMath methods are the same as Math, unlike the results obtained are the same as those produced by fdlibm (Freely Distributable Math Library). More in the class description StrictMath: http://java.sun.com/j2se/1.5.0/docs/...trictMath.html
    # Math 1.0 (Jakarta Commons): This API (available at: http://jakarta.apache.org/commons/math/) provides the Java developer a greater number of mathematical and statistical algorithms. More information in the documentation: http://jakarta.apache.org/commons/ma...ide/index.html.

  5. #5
    Join Date
    Oct 2005
    Posts
    2,393

    Re: Java ME SDK 3.0 Math Class

    Java.lang.Math class contains a series of mathematical methods and variables. As the Math class is part of the java.lang package, it is automatically imported. Moreover, it is not necessary to declare an object of type Math because the methods are all static
    Example (Java 1.1):
    Code:
     Calculate and display the square root of 3
    public class math1 (
      public static void main (java.lang.String[] args) (System.out.println ("=" + Math.sqrt (3.0));))

  6. #6
    Join Date
    Nov 2005
    Posts
    1,323

    Re: Java ME SDK 3.0 Math Class

    Methods sin () cos () tan (), asin (), acos () atan () is declared: public static double fonctiontrigo (double angle). The angles must be expressed in radians. To convert degrees to radians, simply multiply by PI/180. These methods exist for the types int, long, float and double: they determine respectively the maximum and minimum values of two parameters.
    Code:
    public class math1 
    public static void main (String[] args) (System.out.println ("biggest =" + Math.max (5, 10)) System.out.println ("the smallest =" + Math.min (7, 14));))
    Result:
    largest = 10 = 7 the smallest

Similar Threads

  1. Converting java class to java bean class
    By Ucchal in forum Software Development
    Replies: 6
    Last Post: 09-08-2010, 10:24 AM
  2. Graphics2D class of java
    By GurdeepS in forum Software Development
    Replies: 5
    Last Post: 26-02-2010, 02:39 PM
  3. RecordStore class in java
    By Level8 in forum Software Development
    Replies: 4
    Last Post: 12-12-2009, 02:12 PM
  4. Java math question
    By Daren in forum Software Development
    Replies: 2
    Last Post: 02-09-2009, 06:33 PM
  5. Java Programming Language Basics: Reflection Basics and Class Class
    By mayuri_gunjan in forum Guides & Tutorials
    Replies: 6
    Last Post: 29-08-2005, 12:04 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,565,222.48603 seconds with 17 queries