Find Us On: Facebook Twitter Rss Feed Blog
Need To Register? Sign Up Login



import java.util.*; public class HomeworkSep30 { public static void main(String[] args) { int[] arr = { 1, 2, 3, 4, 5 }; boolean containsFive = contains(arr, 5); System.out.println("5 is in this array: " + containsFive); // should be true boolean containsSeven = contains(arr, 7); System.out.println("7 is in this array: " + containsSeven); // should be false int[] countingArray = createCountingArray(10); System.out.println(Arrays.toString(countingArray)); } Write a method called "contains" that takes two parameters, an int array and a number. The method should return true if the number is in the array. It should return false otherwise. public static boolean contains() { } Write a method called "createCountingArray" that takes one int parameter. The method should create and return a new array with numbers counting up. For example, createCountingArray(4) should return an array like {1, 2, 3, 4} public static int[] createCountingArray(...) { // your code here } } Attachments
Tags Clarifications


JAVA ARRAY: Implement counting array and contains


Provided you will find the implemented requirements with some comments how the implementation works. Attachments (1 K) Download Preview
{ return true; } } return false; } public static int[] createCountingArray(int num) { // create a new array with the size of the given number int[] array = new int[num]; //loop through the array with a for-loop begining from // element 1 (i=1); for (int i = 1; i

Purchase Answer