public static void ten(String number, int power) {
String two = number;
char[] arr = two.toCharArray();
arr = reverseArray(arr);
int i = 0;
Double rs = 0.0;
for (char c : arr) {
i++;
String str = String.valueOf(c);
int n = Integer.parseInt(str);
Double r = n * Math.pow(power, i - 1);
rs += r;
}
System.out.println(rs);
}
public static char[] reverseArray(char[] array) {
char[] newArray = new char[array.length];
for (int i = 0; i < newArray.length; i++) {
newArray[i] = array[array.length - i - 1];
}
return newArray;
}
|