Question: 2: Longest Streak [10 marks] *In the provided Problem2.java file, complete the method called longestStreak. There should be no other methods or attributes in your

 2: Longest Streak [10 marks] *In the provided Problem2.java file, complete

2: Longest Streak [10 marks] *In the provided Problem2.java file, complete the method called longestStreak. There should be no other methods or attributes in your class. The contract (specification) of the method is given below public static int longestStreak (boolean L] values) /* Purpose: computes the length of a longest streak of consecutive true occurrences in the input argument values * Input: values is a non-null array of booleans with length at least 1 * *output : outputs the maximal number of consecutive trues found ln the input array Do not change the method signature (use the provided skeleton java file). Changing the method modifiers, return type, name or input arguments will result in zero correctness marks for this problem Mark breakdown: 2 for style, 8 for correctness Put your Problem2.java file in your assignment1.zip file Examples: Your longestStreak method should behave as follows boolean[] test-case = new boolean []{false, true, true, false); Problem2.longestStreak ( test.case)>2 test-case = new boolean[] {false); Problem2.longestStreak( test.case) erurns^ o test-case = new boolean []{true, false, true); Problem2. longestStreak( test-case )- 1 test-case = new boolean []{false, true, true, true, false, true, true, true); Problem2. longestStreak ( test-case ) 13 returns returns returns returns Note: Examples are provided as a guide to help you get your programs/methods working as specified. However, having your code match the examples is not a guarantee that your code will receive high correctness marks. You must test your code more extensively

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 Databases Questions!