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) {
//who's idea was this?
int n=672;
int sum=0;
while (n>0)
{
sum=sum+n%10;
n=n/10;
sum=sum+n%10;
n=n/10;
sum=sum+n%10;
n=n/10;
}
return sum;
}
}

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) {
//who's idea was this?
int n=672;
int sum=0;
while (n>0)
{
sum=sum+n%10;
n=n/10;
sum=sum+n%10;
n=n/10;
sum=sum+n%10;
n=n/10;
}
return sum;
}
}