Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem #1 doubleSquares () In order to implement this method, you will need to add Rectangle class to your project. The method takes an array

Problem #1

doubleSquares ()

In order to implement this method, you will need to add Rectangle class to your project.

The method takes an array of objects of type Rectangle. Among all the rectangle objects it finds those that are actually squares (length==width) and doubles the values of their length and width fields. The method does not return any result, it just changes the given array.

Problem #2

removeInRange ()

This method takes an ArrayList of integers and a range defined by two integer parameters named "from" and "to". The method removes all values from ArrayList that fall in the range[from, to]. It must make no more than one pass through the ArrayList when removing the values.

If the ArrayList is empty, the method does not do anything.

If "from"value is greater than "to"value, the method throws an IllegalArgumentException

Examples:

ArrayList aListis holding [2, 5, 33, 1, 6, 18]

removeInRange(aList, 1, 5) => [33, 6, 18]

removeInRange(aList, 35, 77) => [2, 5, 33, 1, 6, 18]

removeInRange(aList , 0, 100) => [ ]

Requirement

Use of lambda expressions in your solution is prohibited

Problem 3

repeat ()

This method takes an ArrayList of strings and an integer k. The method modifies the ArrayList by repeating each string it originally contains k times. The method throws IllegalArgumentException when k is negative or a 0.

Example:

ArrayList aListis holding ["How", "are", "you?"]

repeat(aList, 3) => ["How", "How", "How", "are", "are", "are", "you?", "you?", "you?"]

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

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions