Write a static method that takes int number as input argument and returns the sum of the digits of that number.

sum the digits of a number

public CheckSum {

public static void main (String []args){


public static int digitSum(int number) {
	int sum = 0;
        while (number != 0)
            sum = sum + number % 10;
            number = number/10;
    return sum;
build mobile apps in abuja

Check if a given number is perfect square in Java

Add a Comment

Your email address will not be published. Required fields are marked *