[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2008-11-10
7
Medium Priority
?
1,296 Views
Last Modified: 2013-12-22
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
Comment
Question by:cscdubai
  • 4
  • 3
7 Comments
 

Author Comment

by:cscdubai
ID: 22927941
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
 
LVL 5

Accepted Solution

by:
qasitouch earned 2000 total points
ID: 22928244
i have already given answer to similar question.

follow the link

http://www.experts-exchange.com/Programming/Languages/Java/Q_23228505.html
0
 

Author Comment

by:cscdubai
ID: 22928291
Thanks for replying...


is there any math library in J2ME??
if yes how can use it ?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 5

Expert Comment

by:qasitouch
ID: 22929022
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
 

Author Comment

by:cscdubai
ID: 22929561
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
 
LVL 5

Expert Comment

by:qasitouch
ID: 22929868
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
 
LVL 5

Expert Comment

by:qasitouch
ID: 22937550


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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
A solution for Fortify Path Manipulation.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses
Course of the Month19 days, 22 hours left to enroll

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question