package base.project; import javax.swing.*; public class BaseProject { public static String output = ""; private static void convertobase(int n, int i){ output += "\n the number " + n + " converted to base " + i; while (n > 0){ output += " " + n%i; n = n / i; } output += "\n is " + output; JOptionPane.showMessageDialog(null, output); } public static void main(String[] args) { while (true){ String input = JOptionPane.showInputDialog("enter any integer number \n"); int n = Integer.parseInt(input); String in = JOptionPane.showInputDialog("\n Make the folowing selection" + "\n to convert to decimal number" + "\n2 to conver to base 2" +"\n5 to convert to base 5" + "n7 to conver to base 7" + "\n8 to convert to base 8"); int selection = Integer.parseInt(in); switch(selection){ case 2: convertobase(n, 2); break; case 5: convertobase(n, 5); break; case 7: convertobase(n, 7); break; case 8: convertobase(n, 8); break; } } } }
convertobase
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)