The code I have is not even technically my own. I looked around at all the questions, I copied this down, but I still don't understand any of it. What does number%10 do? Why do we do number = number / 10 + number / 10 + number / 10? I don't understand the concept, did I miss when this was taught to us? Pls Help.
package com.codegym.task.task01.task0132;
/*
Sum of the digits of a three-digit number
*/
public class Solution {
public static void main(String[] args) {
System.out.println(sumDigitsInNumber(546));
}
public static int sumDigitsInNumber(int number) {
int sum;
int n;
while (number>=0){
n = number%10;
sum = sum + n;
number = number / 10 + number / 10 + number / 10;
}
return sum;
//write your code here
}
}