Link to home
Start Free TrialLog in
Avatar of cscdubai
cscdubaiFlag for United Arab Emirates

asked on

Urgent: How to convert java program into J2ME????

I developed a java program and it is working on J2EE but when I was trying to run it on J2ME,  I had lots of ERRORS... can you pls help me to find the soution for my problem.

Pls help to make it run in a appropriate way....
import java.io.*;
import java.util.Random;
 
public class math
{
@SuppressWarnings("deprecation")
public static void main (String[] args)throws IOException
{
DataInputStream stdin = new DataInputStream (System.in);
if (stdin == null){
	System.out.println("Please Insert Valid number");
}
 
Random generator = new Random();
int num1;
int num2;
double guess;
double answer;
String string1;
String Quesno;
int incno = 1;
int count = 1;
int score = 0;
 
try{
while (count < 11){
 
char[] st = new char[]{'+','-','*'};
int r = generator.nextInt(st.length);
 
num1 = generator.nextInt(10); //Gets random num1
 
num2 = generator.nextInt(10); //Gets Random num2
 
char randomChar = st[r];
 
Quesno = "Question Number " + incno + " : ";
System.out.println (Quesno + num1 + randomChar+ num2);
incno++;
 
if (randomChar == '*'){
answer = (num1*num2);
}
else if (randomChar == '/'){
	answer = (num1/num2);
}
else if (randomChar == '-'){
	answer = (num1 - num2);
}
else
answer = (num1+num2);
 
string1 = stdin.readLine();
guess = Double.parseDouble(string1);
 
if (guess == answer)
{ 
System.out.println("Correct, Question (1) answer is " + answer);
score ++;
} 
else
{ 
System.out.println("Wrong Answer, it is "+answer+" Guess again");
} 
count++;
}
	
System.out.println ("END of Questions");
System.out.println ("Your Score is "+score+"/10");
 
			}catch (EOFException e){
		}
	}
}

Open in new window

Avatar of cscdubai
cscdubai
Flag of United Arab Emirates image

ASKER

I asked This qustion before more than 12 hours, and until now I didn't have any answer for that !!!!
I think you mentioned that if it's urgent you will answer with in 12 hours, but I didn't get any thing yet...
ASKER CERTIFIED SOLUTION
Avatar of qasitouch
qasitouch
Flag of Pakistan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for replying...


is there any math library in J2ME??
if yes how can use it ?
welcome

java.lang.Math

Math.log() is not available CLDC 1.1 , CLDC 1.1 supports floating point
types, includes several more methods in java.lang.Math, but CLDC's
 is still a subset of the J2SE version of the
class.
why J2me shows this Error for IOExeption and how can I resolve it?


C:\WTK22\apps\math\src\math1.java:8: cannot find symbol
symbol  : class IOException
location: class math1
public static void main (String[] args)throws IOException
u have the answer of your 1st question and now u r asking too  many questions in a single question.


do write your code which is generation exception in another question and i'll answer u there.






I have given the answer to this question and the author started new question in the same question and after getting his answer, he is wants this question to be deleted.

I want the 500 points.