Question: Problem 3 . - Write a program that has the class name Problem 3 and that has the main method. Leave the main method empty

Problem 3.
- Write a program that has the class name Problem3 and that has the main method. Leave the main method empty for now.
- Write a method named greaterThanSum that takes one parameter, an integer array a and returns a new integer array \( x \).
- The method finds all the terms of an array a that are greater than the sum of all previous terms of the sequence. If there are no such elements, you can return an empty array.
- Several sample usages are provided for you below. Use the sample usages in the main method to test your code. Create a printArray method that takes an integer array as a parameter and prints out the elements of the array on the same line separated by a comma and space.
\begin{tabular}{|l|c|}
\hline \multicolumn{1}{|c|}{ Sample Method Usage } & Return value \\
\hline \begin{tabular}{l}
int[] a1\(=\{1,4,16,-19,-12,2,5\} ; \)\\
int[] x1\(=\) greaterThanSum(a1);
\end{tabular} & \(\{1,4,16,2,5\}\)\\
\hline \begin{tabular}{l}
int[] a2\(=\{-1,-2,-4,-12 ~\} ; \)\\
int[] x2\(=\) greaterThanSum(a2);
\end{tabular} & \(\{\)\}\\
\hline \begin{tabular}{l}
int[] a3\(=\)\{29,-10,22,5,-15,19,62\}; \\
int[] x3\(=\) greaterThanSum(a3);
\end{tabular} & \(\{29,22,62\}\)\\
\hline \begin{tabular}{l}
int[] a4\(=\{\)5,8,17,50\}; \\
int[] x4\(=\) greaterThanSum(a4);
\end{tabular} & \(\{5,8,17,50\}\)\\
\hline
\end{tabular}
Problem 3 . - Write a program that has the class

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!