-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLesson 15.java
More file actions
36 lines (31 loc) · 805 Bytes
/
Lesson 15.java
File metadata and controls
36 lines (31 loc) · 805 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Student: Griffin Gowdey.
// Instructor: Daniel Goodman.
// Class Number: ITSE1479-86039.
// Class Name: Java Programming.
// Semester: Fall 2020.
// Lesson 15.
/*
Assignment:
Write a method:
public static void downsize(LinkedList<String> employeeNames, int n)
that removes every nth employee from a linked list.
*/
import java.util.LinkedList;
public class Lesson15
{
/*
Removes every nth element from the linked list.
@param employeeNames the linked list to remove from.
@param n the parameter to determine "nth".
*/
public static void downsize(LinkedList<String> employeeNames, int n)
{
for (int i = employeeNames.size() - 1; i >= 0; i--)
{
if ((i + 1) % n == 0)
{
employeeNames.remove(i);
}
}
}
}