Skip to content

Instantly share code, notes, and snippets.

@godie007
Created June 1, 2012 20:58
Show Gist options
  • Save godie007/2855105 to your computer and use it in GitHub Desktop.
Save godie007/2855105 to your computer and use it in GitHub Desktop.
package Trabajo;
public class DecimalAOctal {
public static void main(String[] args) {
octalADecimal("765");
}
public static void octalADecimal(String base) {
String cadenaInver = "";
int b = 0;
int c = 0;
for (int i = base.length()-1; i >= 0; i--) {
cadenaInver += ""+base.charAt(i);
}
for (int i = 0; i <= cadenaInver.length(); i++) {
String convertir = "" + cadenaInver.charAt(i);
b = Integer.parseInt(convertir);
c += Math.pow(b*8, i);
}
System.out.println(c);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment