Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1-give the answer for the following: a-Write a method called copy, which is passed A[], which is an array of int, and an integer n.

1-give the answer for the following:

a-Write a method called copy, which is passed A[], which is an array of int, and an integer n. The method returns a new array consisting of the first n items in A[].

b-Write a method called slice, which is passed A[], which is an array of int, an integer i and an integer j. The method returns a new array consisting of all of the items in A from A[i] to A[j] inclusive.

c-Write a method called copy, which is passed A[], which is an array of int, and an integer n. The method returns a new array consisting of all of the items in A[] which are greater or equal to n.

2-give the answer

a-Write a method which is passed an array of int and returns true if the array is sorted in ascending order.

b-Write a method called generateTriangleNumbers(). This method will take in an integer x and will return an array of integers containing the first x triangle numbers. The nth triangle number is the sum of 1 + 2 + 3 + 4...(n 1) + n.

generateTriangleNumbers(3) returns the array {1,3,6}

generateTriangleNumber(1) returns the array {1}

generateTriangleNumbers(7) returns the array {1, 3, 6, 10, 15, 21, 28}

c-Write a method which is passed a String and returns the String in reverse.

3-Write the methods for the following

a-Write a method which is passed an array of String and modifies it so that all the Strings in the array are reversed. For example, if we pass the array: {"apple", "banana", "racecar", "abc"} the method transforms it to: {"elppa", "ananab", "racecar", "cba"}

b-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.

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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Microsoft SQL Server 2012 Administration

Authors: Adam Jorgensen, Steven Wort

1st Edition

1118106881, 9781118106884

More Books

Students also viewed these Databases questions