Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

IN JAVA PLEASE Write a method which is passed an array of int[ ] A and an int t

ID: 3704059 • Letter: I

Question

IN JAVA PLEASE

Write a method which is passed an array of int[ ] A and an int t (for threshold). The method returns the number of odd items in A which are greater than or equal to t.
Write a method which is passed a two dimensional array of int A[][], and an int t. The method returns the index of the row in A which contains the greatest number of odd numbers greater than or equal to t. The method returns -1 if no row has any odd numbers greater than t. You may use your answer to part a in your answer to this part.

Write a method which is passed a two-dimensional array of int row by row. Do not assume that each row has the same number of columns.

Write a method which is passed a two-dimensional array of int column by column.

Implement the method:

Write a method which is passed a String which returns true if the String contains a double letter or false otherwise.

Write a method which is passed a String. It returns the index of the last Roman Numeral (recall that the Roman Numerals are {'I', 'V', 'X', 'L', 'C', 'D', 'M'}) found in the String or -1 if no Roman Numeral is found in the String.

Write a method which is passed a String s and returns a String that's exactly the same as s, but with no vowels.

Write a method which is passed a String s and returns a new String that's the same as s, but with the first letter of each word capitalized. There is a static method in the Character class toUpperCase that is passed a char c. If c is a lower-case letter, it returns its upper case equivalent. If it's not a lower-case letter, it returns c.

Write a method called acronym, which is passed a String s and returns a new String consisting of the first letter of each word in s. For example, if s refers to the String "United Parcel Service", the method returns the String "UPS"

Explanation / Answer

// Write a method which is passed an array of int[ ] A and an int t (for threshold). The method returns the number of odd items in A which are greater than or equal to t.
public static int oddThreshold(int[] A, int t) {
int n = 0;
for (int i = 0; i < A.length; i++) {
if (A[i] %2 == 0 && A[i] >= t) {
n++;
}
}
return n;
}
  
// Write a method which is passed a two dimensional array of int A[][], and an int t. The method returns the index of the row in A which contains the greatest number of odd numbers greater than or equal to t. The method returns -1 if no row has any odd numbers greater than t. You may use your answer to part a in your answer to this part.
public static int rowOddThreshold(int[][] A, int t) {
int n = -1;
for (int i = 0; i < A.length; i++) {
int rowN = oddThreshold(A[i], t);
if (rowN != 0 && rowN > n) {
n = rowN;
}
}
return n;
}
  
// Write a method which is passed a two-dimensional array of int row by row. Do not assume that each row has the same number of columns.

// Write a method which is passed a two-dimensional array of int column by column.

/* sets every value in A[][] to initVal */
public static void initialize(int A[][], int initVal) {
for (int i = 0; i < A.length; i++) {
for (int j = 0; j < A[i].length; j++) {
A[i][j] = initVal;
}
}
}