Fill the insertCommas method to recursively construct and return a string representation of the parameter num, including commas for every third decimal place. Ex. 157992546 >>>>> 157,992,546 import java.util.*; public class NumbersWithCommas{ public static String insertCommas(int num){ } public static void main(String[] args){ int numTests =(int)(Math.random() * 6) + 5; for (int i = 0; i < numTests; i++){ int num = (int)(Math.random() * Integer.MAX_VALUE); System.out.println(num + " >>>>> " + insertCommas(num)); } System.out.println(1000000 + " >>>>> " + insertCommas(1000000)); System.out.println(1001020 + " >>>>> " + insertCommas(1001020)); System.out.println(561010002 + " >>>>> " + insertCommas(561010002)); } }
Fill the insertCommas method to recursively construct and return a string representation of the parameter num, including commas for every third decimal place. Ex. 157992546 >>>>> 157,992,546
import java.util.*;
public class NumbersWithCommas{
public static String insertCommas(int num){
}
public static void main(String[] args){
int numTests =(int)(Math.random() * 6) + 5;
for (int i = 0; i < numTests; i++){
int num = (int)(Math.random() * Integer.MAX_VALUE); System.out.println(num + " >>>>> " + insertCommas(num));
}
System.out.println(1000000 + " >>>>> " + insertCommas(1000000)); System.out.println(1001020 + " >>>>> " + insertCommas(1001020)); System.out.println(561010002 + " >>>>> " + insertCommas(561010002));
}
}
Trending now
This is a popular solution!
Step by step
Solved in 2 steps