问题:给定一个数字 N。任务是完成函数 convertFive(),它将数字中的所有零替换为 5 我的代码| 请验证任何帮助我
public class Replaceall0swith5 {
public static void convertFive(int n) {
//add code here.
int digit, sum = 0;
while (n > 0) {
digit = n % 10;
if (digit == 0) {
digit = 5;
}
sum = sum * 10 + digit;
n = n / 10;
}
System.out.print(n + " All O's replaced with 5 " + sum);
}
public static void main(String[] args) {
Replaceall0swith5.convertFive(1004);
}
}