Question: Using Java Language Programming, try to solve the last problem: 1. Write a method to return the number of digits in a long parameter. Ex.

Using Java Language Programming, try to solve the last problem:

1. Write a method to return the number of digits in a long parameter.

Ex. given 189 the method should return 3

Ex. given 203758 the method should return 6

2. Write a second method that displays the sum of the digits of a long parameter.

Ex. given 189 the method should return 18

Ex. given 203758 the method should return 25

3. Write a main method to test the methods in question 1 and 2. You should get an input value from the keyboard and then call both methods. Sample output:

Enter a number: 123 --> (User) 123 has 3 digits --> (Output)

sum = 6 --> (Output also)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!