0% found this document useful (0 votes)
49 views

1.arraylist Funhouse1

This document describes a lab assignment to use ArrayLists to return the factors of integers and remove non-composite numbers. It provides sample code to define methods to get factors and filter for composites. It also includes sample input/output.

Uploaded by

Elmer Yang
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views

1.arraylist Funhouse1

This document describes a lab assignment to use ArrayLists to return the factors of integers and remove non-composite numbers. It provides sample code to define methods to get factors and filter for composites. It also includes sample input/output.

Uploaded by

Elmer Yang
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 1

A+ Computer Science

Lab Goal :

ArrayList Factors and Composites

Lab Value - 100

This lab was designed to introduce and demonstrate how to use an ArrayList.

Lab Description :

Create a method that will receive an integer parameter and then return an ArrayList
that contains all of the numbers factors, excluding 1 and itself. Create a 2 nd method that will remove all
numbers from its ArrayList parameter that are not composite numbers. Composite numbers are divisible by 1,
itself, and must have at least 1 other positive factor. You will need to use % to determine if a number is a
factor.
public class ArrayListFunHouse
{
public static ArrayList<Integer> getListOfFactors(int number)
{
// you will add code
}
public static void keepOnlyCompositeNumbers( List<Integer> nums )
{
// you will add code
}
}

Files Needed ::

Sample Data :
9
23
50
100
762
2 6 8 9 10 12 13 15 17 24 55 66 78 77 79

ArrayListFunHouse.java
ArrayListFunHouseRunner.java

Sample Output :

[3]
[]
[2, 5, 10, 25]
[2, 4, 5, 10, 20, 25, 50]
[2, 3, 6, 127, 254, 381]
Original List
[2, 6, 8, 9, 10, 12, 13, 15, 17, 24, 55, 66, 78, 77, 79]
Composite List
[6, 8, 9, 10, 12, 15, 24, 55, 66, 78, 77]

A+ Computer Science ArrayList - www.apluscompsci.com

You might also like