Write a static method printNumber that takes an array of integers that represent
ID: 3531828 • Letter: W
Question
Write a static method printNumber that takes an array of integers that represent the
digits of a large integer and that prints the integer with commas between every 3 digits starting from the right.
You may assume that the values in the array are all between 0 and 9 and that there are no leading 0's. For
example, if the array contains the digits (1, 5, 0, 0), then your method should produce the following output:
1,500
If the array instead contains the digits (3, 8, 4, 9, 2, 1, 4, 7), then your method should produce the following
output:
38,492,147
Your method might not print any commas if the number is small enough. For example, if the array contains the
digits (2, 5, 0), then your method should produce the following output:
250
Your method should produce an entire line of output so that if it is called several times in a row, each call will
produce a separate line of output. Write your method in a class named CommaPrinter.
Explanation / Answer
spaces"); for (int i=0; i<="" p="">
spaces"); for (int i=0; i<="" p="">
This is my test code:
public class SmallestIndex { //variables
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.