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

1 Expert Approved Answer
Step: 1 Unlock

Java program named SumDigitsjava that implements the described functionalit... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!