Question: Write a method called stretch that takes an integer as a parameter and that increases a list of integers by a factor of by replacing
Write a method called stretch that takes an integer as a parameter and that increases a list of integers by a factor of by replacing each integer in the original list with copies of that integer. For example, if a variable called list stores [18, 7, 4, 24, 11] and we make the call of list.stretch(3); the list should be changed to store [18, 18, 18, 7, 7, 7, 4, 4, 4, 24, 24, 24, 11, 11, 11]. If is zero or negative, the list should become empty.
Step by Step Solution
3.40 Rating (169 Votes )
There are 3 Steps involved in it
public void stretch int n if n 0 ensureC... View full answer
Get step-by-step solutions from verified subject matter experts
