Details of this Paper

Count Array




The learning objective of this question is to illustrate the power of Java inheritance and polymorphism. Your response to this question is in multiple parts. You will submit your answers as specified at the end of this question.;To help you get started and to guide your development efforts for this assignment we have provided scaffolding code. Download and unzip the BlueJ project Study the code along with the description below. Edit the code and submit the completed BlueJ project. We have also provided a unit test file to help you check your code.;Now, let us look at the question.;Consider an array of integers as below;int[] a = {5, 2, -4, 3, 0, -5, 7, 11, 6, 13};Complete the method named count(int[] a) in the class Count. The method should return the number of positive numbers in the array. Thus count(a) should return 7 (not counting the 2 negative numbers and 0).;On examining your code for count (your solution to part-a), you will see a test similar to this: if (a[i]>0) {...}. If we were to now ask you to modify the count method so that it counted the number of negative numbers, it would be trivial: All that you would have to do is change the greater-than comparison operator (?>?)to the less-than operator (?


Paper#64021 | Written in 18-Jul-2015

Price : $27