• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1300
  • Last Modified:

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

0
cscdubai
Asked:
cscdubai
  • 4
  • 3
1 Solution
 
cscdubaiAuthor Commented:
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...
0
 
qasitouchCommented:
i have already given answer to similar question.

follow the link

http://www.experts-exchange.com/Programming/Languages/Java/Q_23228505.html
0
 
cscdubaiAuthor Commented:
Thanks for replying...


is there any math library in J2ME??
if yes how can use it ?
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
qasitouchCommented:
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.
0
 
cscdubaiAuthor Commented:
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
0
 
qasitouchCommented:
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.




0
 
qasitouchCommented:


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.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now