Q1_20250829091152.webp
Jellal87

Q1_20250829091152.webp

  • Media owner Jellal87
  • Ngày thêm
creating an Inumber Utilities.java file.
Kizspy.me
<<interface>>
INumber Utilities
+findFirstEvenNumber(numbers: String): int
+sumOfDigits(number: int): int
Write a class named Number Processor, which implements the interface INumberUtilities. The
class NumberProcessor implements all methods in IUtilities as below:
⚫ findFirstEvenNumber(numbers: String): int - finds and returns the first even number in the
string of numbers. If no even number is found or the string is empty/null, it returns -1.
⚫ sumOfDigits (number: int): int returns the sum of all digits in the given number. The
number can be a negative or a positive number.
Hints: You can refer to the methods: split() of the String class; abs() of the Math class.
Do not format the result.
The program output might look something like this:
1. Test findFirstEvenNumber
2. Test sumOfDigits
Enter Test Case No. (1/2): 1
Enter a string of numbers: 3 5 7 9 10 12 14
1. Test findFirstEvenNumber
2. Test sumOfDigits
Enter Test Case No. (1/2): 2
Enter a number: -987
Zoom
+ 100%
Close
Chưa có bình luận nào.

Thông tin

Category
PRO192
Thêm bởi
Jellal87
Ngày thêm
Lượt xem
3,813
Lượt bình luận
0
Rating
0.00 star(s) 0 đánh giá

Share this media

Back
Bên trên Bottom