import java.util.Scanner;
/*
* 编写方法,将八进制数转换为十进制数。Integer.valueOf("876",8).toString()
* */
public class OctalToDecimal {
public static void main(String[] args) {
String oldValue;
System.out.print("Input the an Octal number:");
oldValue = new Scanner(System.in).next();
String newValue;
newValue = OctalToDecimal.toDecimal(oldValue);
System.out.print(newValue);
}
public static String toDecimal(String oldValue)
{
String integer = Integer.valueOf(oldValue,8).toString();
return integer;
}
}
时间: 2024-10-14 18:43:56