Question: Write a program SumDigits.java that perform the following: Define a function addDigits that computers the sum number 2345 returns 14 (2+3+4+5). Write a program that
"Write a" program SumDigits.java that perform the following:
Define a function addDigits that computers the sum number 2345 returns 14 (2+3+4+5).
"Write a" program that asks user to enter 4 digit a number and print out the sum of its digits using the method above. if the user enters a number that is not 4 digits, print an invalid input message. Repeat until user wants to quit.
sample output
Enter a 4 digit number (-1 to quit): 2345
Sum of the digits of 2345 is 14
Enter a 4 digit number (-1 to quit): 123456
Invalid input. Please enter a 4 digit number
Enter a 4 digit number (-1 to quit): 3456
Sum of the digits of 3456 is 18
Enter a 4 digit number (-1 to quit): -1
Step by Step Solution
There are 3 Steps involved in it
Java program named SumDigitsjava that implements the described functionalit... View full answer
Get step-by-step solutions from verified subject matter experts
