Sum of Digits
In this lab, you will develop a Java method named sumOfDigits
. This method takes an integer as input and returns a singledigit integer by summing the digits repeatedly until only a single digit remains.
Method Specification
 Method Name:
sumOfDigits
 Input: An integer (
int
).  Output: A singledigit integer (
int
).
Task
Your task is to implement the sumOfDigits
method in the Main
class. This method should continuously sum the digits of the input number until the sum is a single digit.
Edge Cases and Examples

SingleDigit Input: If the input is already a single digit, the method should return the input itself.
 Example: For input
5
, the output should also be5
.
 Example: For input

MultiDigit Input: For multidigit inputs, the method should add up all the digits and, if the result is more than one digit, continue summing the digits of the result until a single digit is obtained.
 Example: For input
129
, the sum is1 + 2 + 9 = 12
. Since12
is not a single digit, sum its digits:1 + 2 = 3
. The output should be3
.
 Example: For input
Requirements
 Implement the
sumOfDigits
method in a class namedMain
.  Ensure the method handles both singledigit and multidigit inputs correctly.
 Pay special attention to edge cases to ensure your method can handle any integer input within the bounds of the
int
data type.
This lab challenges your ability to write efficient and accurate Java code, focusing on iterative processing and condition handling. Good luck!
Challenges
Challenge 1: Validate Method Name and Return Type
Objective: Verify that the method is correctly named sumOfDigits
and returns an int
type.
 Requirement: The method must be named
sumOfDigits
.  Return Type: The method should return an integer (
int
).  Details: Confirm the existence of the
sumOfDigits
method and ensure it is designed to return anint
.
Challenge 2: Test Case for Single Digit Argument
Objective: Ensure the method correctly handles a singledigit input.
 Input: A singledigit integer (e.g., 5).
 Expected Behavior: The method should return the input itself, as the sum of a singledigit number is the number itself.
 Details: Test the method with a singledigit input and expect the output to be identical to the input.
Challenge 3: Test Case for Double Digit Argument
Objective: Test the method with a doubledigit input.
 Input: A doubledigit integer (e.g., 34).
 Expected Behavior: The method should sum the digits and continue summing until a single digit is obtained.
 Details: Provide a doubledigit number and verify that the method correctly reduces it to a single digit.
Challenge 4: Test Case for Triple Digit Argument
Objective: Assess the method's handling of a tripledigit input.
 Input: A tripledigit integer (e.g., 129).
 Expected Behavior: The method should sum the digits and continue the process until a single digit is reached.
 Details: Test the method with a tripledigit input and confirm it properly reduces it to a single digit.
Challenge 5: Test Case for Five Digit Argument
Objective: Evaluate the method's performance with a fivedigit input.
 Input: A fivedigit integer (e.g., 54321).
 Expected Behavior: The method should sum the digits iteratively until a singledigit sum is obtained.
 Details: Input a fivedigit number and check that the method accurately reduces it to a single digit.