Created
June 1, 2012 20:58
-
-
Save godie007/2855105 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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