Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. package baseconversion;
  2.  
  3. import java.util.*;
  4.  
  5. public class BaseConversion {
  6.  
  7. static Scanner input = new Scanner(System.in);
  8.  
  9. public static String convert (int num, int b, String total) {
  10.  
  11.  
  12. if (num % b == 0) return total;
  13.  
  14. if (num % b > 0) {
  15. return total + "" + b;
  16. }
  17.  
  18. return convert(num, b, total);
  19. }
  20.  
  21. public static void main(String[] args) {
  22.  
  23. String mainTotal = "";
  24.  
  25. System.out.println("Input a number");
  26. int mainNum = input.nextInt();
  27. System.out.println("Input the base case");
  28. int mainB = input.nextInt();
  29. convert(mainNum, mainB, mainTotal);
  30.  
  31. System.out.println(mainTotal);
  32. }
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement