64 669
Assignments Done
99,2%
Successfully Done
In September 2018

Answer to Question #67172 in Java | JSP | JSF for john ryan

Question #67172
Write a program that will accept an array of 10 integer (0-999) then prints a table the equivalent binary, octal
and hexadecimal.
Expert's answer
public class Main {

public static void main(String[] args) {
int[] arr = new int[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};//example
converter(arr);
}

public static void converter(int[] arr) {
System.out.printf("%1$-11s %2$-11s %3$-11s %4$-11s", "Decimal", "Binary", "Octal", "Hexadecimal");
System.out.println();
for (int i = 0; i < arr.length; i++) {
System.out.printf("%1$-11s %2$-11s %3$-11s %4$-11s", arr[i] + "", Integer.toString(arr[i], 2), Integer.toString(arr[i], 8), Integer.toString(arr[i], 16));
System.out.println();
}
}

}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions