catman2112
08-03-2006, 05:10 PM
All right - here's what I needed to do - consider this a class in a grand scheme of classes - it uses proprietary code (Bajaui) in a Java environment -
I needed to take an input variable int, up to 99,999 and take each of the individual numbers out as individual numbers.....
For instance, the number 83746 would yield 8, 3, 7, 4, 6 -
I thougth about sending it to an array - but not sure the syntax for parsing this...
This is what I came up with: and it works -
int m10k, m1k, m100, m10, m1;
int KWUsage = (int)getIn10().getNumeric();
System.out.println(KWUsage);
m10k = (KWUsage/10000);
System.out.println("m10k =" + m10k);
m1k = ((KWUsage - (m10k*10000))/1000);
System.out.println("m1k =" + m1k);
m100 = ((KWUsage - (m10k*10000)) - (m1k*1000))/100;
System.out.println("m100 =" + m100);
m10 = ((KWUsage - (m10k*10000)) - (m1k*1000) - (m100*100))/10;
System.out.println("m10 = " +m10);
m1 = ((KWUsage - (m10k*10000)) - (m1k*1000) - (m100*100) - (m10*10));
System.out.println("m1 = " +m1);
getOut().setValue(m10k);
System.out.println("The Value of Out 1 is " + getOut().getValue());
getOut1().setValue(m1k);
System.out.println("The Value of Out 2 is " + getOut1().getValue());
getOut2().setValue(m100);
System.out.println("The Value of Out 3 is " + getOut2().getValue());
getOut3().setValue(m10);
System.out.println("The Value of Out 4 is " + getOut3().getValue());
getOut4().setValue(m1);
System.out.println("The Value of Out 5 is " + getOut4().getValue());
NOTE: the getOut#() methods and the getIn10() method are part of the proprietary code - if someone can suggest a way to array this I would appreciate it....
I also had to cast the getIn10 to a int because by default, it's a double....
Thanks
I needed to take an input variable int, up to 99,999 and take each of the individual numbers out as individual numbers.....
For instance, the number 83746 would yield 8, 3, 7, 4, 6 -
I thougth about sending it to an array - but not sure the syntax for parsing this...
This is what I came up with: and it works -
int m10k, m1k, m100, m10, m1;
int KWUsage = (int)getIn10().getNumeric();
System.out.println(KWUsage);
m10k = (KWUsage/10000);
System.out.println("m10k =" + m10k);
m1k = ((KWUsage - (m10k*10000))/1000);
System.out.println("m1k =" + m1k);
m100 = ((KWUsage - (m10k*10000)) - (m1k*1000))/100;
System.out.println("m100 =" + m100);
m10 = ((KWUsage - (m10k*10000)) - (m1k*1000) - (m100*100))/10;
System.out.println("m10 = " +m10);
m1 = ((KWUsage - (m10k*10000)) - (m1k*1000) - (m100*100) - (m10*10));
System.out.println("m1 = " +m1);
getOut().setValue(m10k);
System.out.println("The Value of Out 1 is " + getOut().getValue());
getOut1().setValue(m1k);
System.out.println("The Value of Out 2 is " + getOut1().getValue());
getOut2().setValue(m100);
System.out.println("The Value of Out 3 is " + getOut2().getValue());
getOut3().setValue(m10);
System.out.println("The Value of Out 4 is " + getOut3().getValue());
getOut4().setValue(m1);
System.out.println("The Value of Out 5 is " + getOut4().getValue());
NOTE: the getOut#() methods and the getIn10() method are part of the proprietary code - if someone can suggest a way to array this I would appreciate it....
I also had to cast the getIn10 to a int because by default, it's a double....
Thanks