Help with creating a class
I need to create a class to use with another program that will take regular numbers and convert them to roman numerals. So far I have this:
Code Java:
public class Roman {
public Roman(String r){
char c = r.charAt(0);
int value;
if(c=='I') value=1;
else if(c=='V') value=5;
else if(c=='X') value=10;
else if(c=='L') value=50;
else if(c=='C') value=100;
else if(c=='D') value=500;
else if(c=='M') value=1000;
}
public void printRoman(){
System.out.println();
}
public void printInt(){
System.out.println();
}
}
I know i need a loop for the if else if part, but I'm not too sure on what that loop is. Also, i need code after the printRoman part, but I don't know that either. If someone could point me in the right direction, that'd be great.
Re: Help with creating a class
Write out how you'd do this "by hand". Come up with very specific directions that you could give to somebody who doesn't know anything about roman numerals. When you have that, converting it to code should be pretty simple.
Re: Help with creating a class
Re: Help with creating a class
ok ill try that...but im actually looking for help with creating a loop for the statement here so i think that falls under loop and control statements
Re: Help with creating a class
Quote:
Originally Posted by
cdawg_2010
ok ill try that...but im actually looking for help with creating a loop for the statement here so i think that falls under loop and control statements
Okay. And what would you like the loop to do? We can't really answer general "how do I do this" type questions except to point you to google and the basic tutorials.