変換を使用して、基数 10 の数値を任意の基数に変換しようとしています。今、これは私が思いついたコードです。私はこれが完全に間違っているかもしれないという悲しい気持ちを持っています。以下の画像は、このプロセスがどのように行われるかの例です。
http://i854.photobucket.com/albums/ab107/tonytauart/rrrr.png
public static void main(String[] args) {
  int base;
  int number;
    Scanner console = new Scanner(System.in);
    System.out.println("Please enter the base");
        base = console.nextInt();
    System.out.println("Please enter the Number you would like to convert");
        number = console.nextInt();
        System.out.println(Converter(base, number));
}
public static int Converter(int Nbase, int Nnumber){
    int answer;
    int Rcontainer =0;
    int cnt = 0;
    int multiplier;
    int temp;
    double exp;
    if(Nnumber/Nbase == 0){
        cnt++;
        exp = Math.pow(10,cnt); 
        multiplier = (int)exp;
         answer = (Nnumber%Nbase)* multiplier + Rcontainer;
    }
    else
      {
       exp = Math.pow(10,cnt);
       multiplier = (int)exp;
       cnt++;
       temp = Rcontainer;
       Rcontainer = (Nnumber%Nbase)* multiplier + temp;   
       Nnumber = Nnumber/Nbase;
        answer = Converter(Nbase,Nnumber);
       }  
        return answer;
}
}