Question: I don't know what I did wrong I'm missing something or I absolutely messed up. THIS CODE: sum_getImple int total = 0; ----> 1unit of

I don't know what I did wrong I'm missing something or I absolutely messed up.

THIS CODE:

sum_getImple

int total = 0; ----> 1unit of time for(int i = 0; i < nums.size(); i++)

sum_iteratorImple

int total = 0; java.util.Iterator it = nums.iterator(); while(it.hasNext()) return total;

removeEvens_getImple

for(int i = 0; i < nums.size(); i++) if(nums.get(i) % 2 == 0)

removeEvens_iteratorImple java.util.Iterator it = nums.iterator(); while(it.hasNext()) int value = it.next(); if(value % 2 == 0) it.remove();

void double_getImple for(int i = 0; i < nums.size(); i++) value = nums.get(i); nums.set(i, 2 * value);

double_iteratorImple java.util.ListIterator it = nums.listIterator(); 1 unit of time while(it.hasNext()) value = it.next(); 1 unit of time it.set(2 * value);

ASSIGNMENT:

The sum_getImple Method

/** * Get the total of the values in an integer list * @param nums The list of integers * @return The sum of the values */ public int sum_getImple(java.util.List nums) { int total = 0; for(int i = 0; i < nums.size(); i++) { total += nums.get(i); } return total; }

The sum_iteratorImple Method

/** * Get the total of the values in an integer list * @param nums The list of integers * @return The sum of the values */ public int sum_iteratorImple(java.util.List nums) { int total = 0; java.util.Iterator it = nums.iterator(); while(it.hasNext()) { total += it.next(); } return total; }

The removeEvens_getImple Method

/** * Remove the even values from a list of integers. * The method modifies the parameter list. * @param nums The list of integers */ public void removeEvens_getImple(java.util.List nums) { for(int i = 0; i < nums.size(); i++) { if(nums.get(i) % 2 == 0) { nums.remove(i); } } }

The removeEvens_iteratorImple Method

/** * Remove the even values from a list of integers. * The method modifies the parameter list. * @param nums The list of integers */ public void removeEvens_iteratorImple(java.util.List nums) { java.util.Iterator it = nums.iterator(); while(it.hasNext()) { int value = it.next(); if(value % 2 == 0) { it.remove(); } } }

The double_getImple Method

/** * Double the values in a list of integers. * This method modifies the parameter list. * @param nums The list of integers */ public void double_getImple(java.util.List nums) { for(int i = 0; i < nums.size(); i++) { int value = nums.get(i); nums.set(i, 2 * value); } }

The double_iteratorImple Method

/** * Double the values in a list of integers. * This method modifies the parameter list. * @param nums The list of integers */ public void double_iteratorImple(java.util.List nums) { java.util.ListIterator it = nums.listIterator(); while(it.hasNext()) { int value = it.next(); it.set(2 * value); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!