PRO192_-_PE02_-_SP_2025_3836.webp
Q

PRO192_-_PE02_-_SP_2025_3836.webp

☑Kizspy.me
The interface IUtilities below is already given in Java code format, thus you can use it without creating
an IUtilities.java file.:
<<Interface>>
IUtilities
+getPrime(n: int): int
+getCharacterByIndex(strInput: String, index: int):char
Write a class named MyUtilities, which implements the interface IUtilities. The class MyUtilities
implements all methods in IUtilities.
.
getPrime (n: int): int - return the nth prime number (the primes start from 2, ex: 2 3 5 7,...). If n
is less than or equal to 0, return 0. For example: n=3, return the 3th prime number is 5
getCharacterByIndex(strInput: String, index: int): char - return the character at index of the string
strInput in uppercase. If the index is out of range then return the character @
Hints: You can refer to the methods: toLowerCase(), toCharArray(), valueOf() of the String class,
toUpperCase() of the Character class and StringBuffer class
The program output might look something like this:
1. Test getPrime
2. Test getCharacterByIndex
Enter TC (1/2): 1
Enter a number: 3
OUTPUT:
5
1. Test getPrime
2. Test getCharacterByIndex
Enter TC (1/2).2
+100%
1. Test getPrime
2. Test getCharacterByIndex
Enter TC (1/2): 1
Enter a number: -1
OUTPUT:
0
1. Test getPrime
2. Test getCharacterByIndex
Enter TC (1/2).2
Zoom
Close
Chưa có bình luận nào.

Thông tin

Category
PRO192
Thêm bởi
Quốc Khánh1
Ngày thêm
Lượt xem
1,485
Lượt bình luận
0
Rating
0.00 star(s) 0 đánh giá

Share this media

Back
Bên trên Bottom