I'm trying to write a program that inputs a number and a base and converts that number to a base. I have written the following which compiles, but doesn't seem to do the right thing :S Any help would be much appreciated
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.*; public class Question { int inputDec,base,converted; public int Conversion() { InputStreamReader stream = new InputStreamReader(System.in); BufferedReader reader = new BufferedReader(stream); try { int n,b; System.out.print("Enter number:"); n = Integer.parseInt(reader.readLine()); System.out.print("Which base would you like to convert to?"); b = Integer.parseInt(reader.readLine()); converted=toBase(n,b); System.out.println(converted); } catch(IOException e) {return converted; } return converted; } public int toBase(int n,int b) { if (n !=0) { return(n%b); } else return (0); } }