I'm currently trying to write a little code in java that will convert integers to romanian numbers.
So far I got this:
public class Test{
public static void main(String[] args){
int x = Integer.parseInt(args[0]);
if(x>=1000){
int temp= x;
temp=temp%1000;
x=x/1000;
for(int i=x; i>=1; i--){
System.out.print("M");
}
}
}
}
I'm pretty sure it's not the best way to code it but it's my own way and I don't like to change it.
But to continue like that I need to know how I can keep working with temp
?
I want use it in another if-statement which will be outside of this one.
But it doesn't seem to work because temp
only exists inside this if-statement you see in the code.
Isn't there a way to use it outside without removing it from the if-statement? If so, please do tell me.
Aucun commentaire:
Enregistrer un commentaire