So this is what I have so far but it prints out the hexadecimal backwards. How can I switch it to be forwards or is there an easier way to convert the integer to HexDecimal than I'm doing. This is a homework assignment and I'm not allowed to use arrays or predefined methods (I.E .toHexString()).
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
int num = scn.nextInt();
int remainder;
while (num > 0) {
remainder = num % 16;
if (remainder == 10) {
System.out.print("a");
} else if (remainder == 11) {
System.out.print("b");
} else if (remainder == 12) {
System.out.print("c");
} else if (remainder == 13) {
System.out.print("d");
} else if (remainder == 14) {
System.out.print("e");
} else if (remainder == 15) {
System.out.print("f");
} else {
System.out.print(remainder);
}
num = num / 16;
}
}
}