将八进制数转换为十进制数——java

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;

  }

 

}

posted @ 2015-05-27 08:41  天&泽  阅读(1726)  评论(0编辑  收藏  举报