Java Write Method Named Getevendigitsum One Parameter Type Int Called Number Method Return Q43821599
Java
Write a method named getEvenDigitSum with one parameter of typeint called number.
The method should return the sum of the even digits within thenumber.
If the number is negative, the method should return -1 toindicate an invalid value.
EXAMPLE INPUT/OUTPUT:
* getEvenDigitSum(123456789); → should return 20 since 2 + 4 + 6+ 8 = 20
* getEvenDigitSum(252); → should return 4 since 2 + 2 = 4
* getEvenDigitSum(-22); → should return -1 since the number isnegative
NOTE: The method getEvenDigitSum should be defined as public staticlike we have been doing so far in the course.
NOTE: Do not add a main method to the solution code.
Expert Answer
Answer to Java Write a method named getEvenDigitSum with one parameter of type int called number. The method should return the sum…
OR