Write the targetCheck method, which counts the number of times that targetNum appears in the array. The method should return an integer which is the number of times the value is found.
public class NumArray
{
/** Length of the integer array. */
private int arrayLength;
/** Number of instances in which a specific number appears in the integer array. */
private int targetNum;
/** Constructor for NumArray class. Precondition: target is an integer */
public NumArray(int arr[], int target)
{
arrayLength = arr.length;
targetNum = target;
}
/** Checks the array to determine if the array values are sorted in ascending order.
* Returns true if the array is in ascending order; false otherwise.
* Precondition: array.Length > 1
*/
public boolean sortCheck()
{ /* to be implemented in part (a) */ }
/** Finds the number of times that targetNum is found within the array.
* Returns the values stating the number of times found.
*/
public int targetCheck()
{ /* to be implemented in part (b) */ }
}