Question
Write a method that returns the difference of number of digits of two integers x and y. The method subtracts the number of digits in
-
Write a method that returns the difference of number of digits of two integers x and y. The method subtracts the number of digits in y from the number of digits in x and returns the value.
public int Length(int x, int y)
For example, if x=24598 and y=415, the number of digits in x is 5, and the number of digits in y is 3. Then the method returns 2 (that is 5-3).
For example, if x=234 and y=784415, then the method returns -3 (that is 3-6).
-
Write a test program that prompts the user to enter two integers. The program displays whether the first integer has more digits than the second one or less or both have the same number of digit
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started