In: Computer Science
All Hail Modulus Agustus! The modulus operator is used all the time. Realize that if you “mod” any number by a number “n”, you’ll get back a number between 0 and n-1. For example, “modding” any number by 20 will always give you a number between 0-19. Your job is to design (pseudocode) and implement (source code) a program to sum the total of all digits in an input integer number between 0 and 1000, inclusive. Notice that you need to extract individual digits from the input number using the remainder (modulus) and division mathematical operators. For example, if the input number is 123, the sum of its digits is 6. Document your code and properly label the input prompts and the outputs as shown below. PLEASE DO IN JAVA
import java.util.Scanner;
public class SumOfDigits {
public static void main(String[] args) {
int input;
Scanner sc = new
Scanner(System.in);
// reading input from the
user
System.out.println("Enter number
between 0-1000");
input = sc.nextInt();
int sum = 0;
int temp=input;
while (input > 0) {
// extracting
the last digit
int reminder =
input % 10;
// adding to
sum
sum = reminder +
sum;
// removing the
last digit
input = input /
10;
}
// printing the sum details
System.out.println("Sum of digits
in " + temp + " is : " + sum);
sc.close();
}
}