plzzz...have some heart to help me....plz...

pls jelp me to create a java program, converting the roman numerals to hindu arabic... you can mail me throughjerrymae_yan8@yahoo.com
[147 byte] By [zaizaimaea] at [2007-10-3 2:51:27]
# 1
WTF?! How often are you going to repost that? http://forum.java.sun.com/thread.jspa?threadID=760388&messageID=4341024#4341024
PhHeina at 2007-7-14 20:40:19 > top of Java-index,Java Essentials,Java Programming...
# 2
What, only one thread today? And stop posting your mail address. The only people who'll mail you are viagra vendors.
CeciNEstPasUnProgrammeura at 2007-7-14 20:40:19 > top of Java-index,Java Essentials,Java Programming...
# 3
Come on Rene, that idiot needs some time to retype all that BS.
PhHeina at 2007-7-14 20:40:19 > top of Java-index,Java Essentials,Java Programming...
# 4
> pls jelp me to create a java program, converting the> roman numerals to hindu arabic... you can mail me> through> jerrymae_yan8@yahoo.comDO YOUR OWN HOMEWORK
RageMatrix36a at 2007-7-14 20:40:19 > top of Java-index,Java Essentials,Java Programming...
# 5

@OP: should you finally read this:

- post your code

- before posting code, read http://forum.java.sun.com/help.jspa?sec=formatting

- tell us what you think it should do

- tell us what it does instead

We can help you solving some problems, but we're not going to create your program for you.

CeciNEstPasUnProgrammeura at 2007-7-14 20:40:19 > top of Java-index,Java Essentials,Java Programming...
# 6

import java.io.*;

class MidtermProject

{

public static int toArabic (String x)

{

int arabica=0;

char chars;

for (int y=0; y<=(x.length()-1); y++)

{

chars=x.charAt(y);

switch (chars)

{

case 'C':

if (x.charAt(y+1)=='M')

{

arabica+=900;

y++;

}

else if (x.charAt(y+1)=='D')

{

arabica+=400;

y++;

}

else

{

arabica+=100;

}

break;

case 'X':

if (x.charAt(y+1)=='C')

{

arabica+=90;

y++;

}

else if (x.charAt(y+1)=='L')

{

arabica+=40;

y++;

}

else

{

arabica+=10;

}

break;

case 'I':

if (x.charAt(y+1)=='X')

{

arabica+=9;

y++;

}

else if (x.charAt(y+1)=='V')

{

arabica+=4;

y++;

}

else if (x.charAt (y+1)== 'I')

{

arabica+=2;

y++;

}

else

{

arabica++;

}

break;

case 'M':

arabica+=1000;

break;

case 'D':

arabica+=500;

break;

case 'L':

arabica+=50;

break;

case 'V':

if (x.charAt(y+1)== 'I')

{

arabica+=6;

y++;

}

else

arabica+=5;

break;

}

}

return(arabica);

}

//main program

public static void main (String [] args)

{

String r_input, ro;

int ans1;

DataInput keyboard=new DataInputStream (System.in);

try

{

System.out.print("Enter a Roman numeral: ");

r_input=keyboard.readLine();

ro=r_input.toUpperCase();

ans1=toArabic(ro);

System.out.println("The Arabic number is: "+ans1);

}

catch (Exception e)

{

System.out.print ("Wrong inPut!");

}

}

}

//this is my program...and there are some roman numrals that are nt functioning....

zaizaimaea at 2007-7-14 20:40:19 > top of Java-index,Java Essentials,Java Programming...
# 7

> @OP: should you finally read this:

>

> - post your code

> - before posting code, read

> http://forum.java.sun.com/help.jspa?sec=formatting

> - tell us what you think it should do

> - tell us what it does instead

>

> We can help you solving some problems, but we're not

> going to create your program for you.

CeciNEstPasUnProgrammeura at 2007-7-14 20:40:19 > top of Java-index,Java Essentials,Java Programming...
# 8
One thing I noticed right away: Incorrect use of DataInputStream. Use a InputStreamReader - you're handling text. Or even a BufferedReader around it.Second thing: always at least let an exception print a stack trace when you caught it.
CeciNEstPasUnProgrammeura at 2007-7-14 20:40:19 > top of Java-index,Java Essentials,Java Programming...
# 9
the problem is when i input X,V,I the output is wronf input...
zaizaimaea at 2007-7-14 20:40:19 > top of Java-index,Java Essentials,Java Programming...
# 10
Another thing that's immediately noticeable is that you're going to skip characters due to the multiple "y++" statements.~
yawmarka at 2007-7-14 20:40:19 > top of Java-index,Java Essentials,Java Programming...
# 11
what is a stack trace? im so sorry im a first timer in java...sowi for my questions
zaizaimaea at 2007-7-14 20:40:19 > top of Java-index,Java Essentials,Java Programming...
# 12

try {

//Something

} catch (RuntimeException e) {

e.printStackTrace();

}

zadoka at 2007-7-14 20:40:19 > top of Java-index,Java Essentials,Java Programming...
# 13

> what is a stack trace? im so sorry im a first timer

> in java...sowi for my questions

} catch(SomeException ex) {

ex.printStackTrace();

}

This will make the exception give you an error message and tell you where in your program the problem occured. Makes it easier to find the cause.

CeciNEstPasUnProgrammeura at 2007-7-14 20:40:19 > top of Java-index,Java Essentials,Java Programming...
# 14
> } catch (RuntimeException e) {Well, RuntimeExceptions are the ones that are usually not caught...
CeciNEstPasUnProgrammeura at 2007-7-14 20:40:19 > top of Java-index,Java Essentials,Java Programming...
# 15
is my formula correct?
zaizaimaea at 2007-7-21 10:00:20 > top of Java-index,Java Essentials,Java Programming...
# 16
> the problem is when i input X,V,I the output is wronf> input...Yep, you use x.charAt(y + 1) even if there is no next char.
PhHeina at 2007-7-21 10:00:20 > top of Java-index,Java Essentials,Java Programming...
# 17
can i make my program shorter? how?
zaizaimaea at 2007-7-21 10:00:20 > top of Java-index,Java Essentials,Java Programming...
# 18
> can i make my program shorter? how?I don't know, I can't read it.Did I mention http://forum.java.sun.com/help.jspa?sec=formatting ?
CeciNEstPasUnProgrammeura at 2007-7-21 10:00:20 > top of Java-index,Java Essentials,Java Programming...