Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 15-07-2010
Member
 
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?
Reply With Quote
  #2  
Old 15-07-2010
Member
 
Join Date: Feb 2008
Posts: 1,848
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%
Reply With Quote
  #3  
Old 15-07-2010
Member
 
Join Date: May 2008
Posts: 2,293
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.
Reply With Quote
  #4  
Old 15-07-2010
Member
 
Join Date: May 2008
Posts: 2,383
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.
__________________
The FIFA Manager 2009 PC Game
Reply With Quote
  #5  
Old 15-07-2010
Member
 
Join Date: Oct 2005
Posts: 2,389
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));))
Reply With Quote
  #6  
Old 15-07-2010
Member
 
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
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Java ME SDK 3.0 Math Class"
Thread Thread Starter Forum Replies Last Post
Converting java class to java bean class Ucchal Software Development 6 09-08-2010 10:24 AM
Graphics2D class of java GurdeepS Software Development 5 26-02-2010 02:39 PM
RecordStore class in java Level8 Software Development 4 12-12-2009 02:12 PM
Java math question Daren Software Development 2 02-09-2009 06:33 PM
Java Programming Language Basics: Reflection Basics and Class Class mayuri_gunjan Guides & Tutorials 6 29-08-2005 12:04 AM


All times are GMT +5.5. The time now is 11:45 PM.