Name:
Date:
ACTIVITY 1
Data, Data, Data!
The ease with which data can be stored, cataloged, and searched in an ever
more-connected society is an important point to understand. Data storage has both
positive and negative implications, and being able to recognize these, as well as how your
actions can contribute to the data being stored, are addressed in the following activity.
1. List two or three sites that you access on a regular basis.
2. In your group, find the privacy policy for your given site and identify two or three
pieces of information that are collected for users of the site.
File Types
3. What does the word delimited mean? Why is this necessary when talking about
data files?
4. Given a data file, how can you determine the type of data that might be contained in
a specific column?
Posing Questions
5. On your own, identify two broad areas of interest that you have. Examples include
health, sports, etc.
AP Computer Science A Student Lab Handout 1
Data Lab: Data, Data, Data!
6. For each of the two areas of interest you identified, determine one question to which
you might want to know the answer. These should be questions that are not easily
answered with an online search. Two examples of questions that are easy to answer
with an online search are who won the 1998 Superbowl (The Denver Broncos), and
what is the height of the world’s tallest building (at the time of publication, Burj Khalifa,
2717 ft/828 m).
Discuss your two questions with your partner and refine your questions based on
their feedback. Write your updated questions below.
Finding Data Sets
Your teacher will provide you with several sites that provide free access to data sets.
Spend a few minutes looking at the sites.
7. Are there data sets that might apply to one of the two questions that you refined
in question 6? Find two different data sets that might be used to answer one of your
questions. List the site and any search criteria used to find the data sets. If not,
consider revising one of your questions so that you can identify an applicable data set.
8. How many records are in each of the data sets you identified? Describe one benefit
of using a larger data set with more records.
Check Your Understanding
9. With your partner, discuss one way that user data captured by a site (whether
knowingly or unknowingly) has contributed to an improvement in the service provided.
Have there been any positive impacts of this data outside of the service or website?
2 AP Computer Science A Student Lab Handout
Data Lab: Data, Data, Data!
10. Do you know how the data in the data set you identified was collected? If so,
please describe. If not, describe one way that the data might have been collected.
11. In your opinion, are there situations where the benefit provided from the data
collected is worth the risk to personal privacy? Why or why not?
AP Computer Science A Student Lab Handout 3
Name:
Date:
ACTIVITY 2
Designing and
Implementing a
Custom Class
You have likely created a class from a given description or specification several times.
This is an important skill, but equally important is the ability to determine essential
information to include when creating a class. What is “essential” can vary based on
perspective, or can be determined by a question that is being asked or a problem that
is attempted to be solved. This activity will give you an opportunity to practice making
this type of determination. Consider the following selection.
[Link]
AP Computer Science A Student Lab Handout 5
Data Lab: Designing and Implementing a Custom Class – Teacher Notes
1. Each row of the table represents an instance of an object. What is the best name for
that object?
2. Your teacher will provide you with a question to answer related to the above table.
Write the question here:
3. You will now design a class to describe that object and answer your given question.
Write the class header:
4. How many instance variables will you create?
5. List the data types and names you will use for the instance variables.
6. Create a new Java file named [Link] and implement the class described
above. Your class should contain all necessary instance variables, constructors,
accessors methods, and a toString method.
Tips
Constructors are not methods and so have no return type. They are special
blocks of code that for the purposes of this class should be declared public
and have the same name as the class.
When assigning values to instance variables the type of variable cannot be
included. If the type is included before the variable name in the constructor,
this creates a local variable of the same name that is initialized and the
instance variables of the object are never initialized. Once the constructor
is complete the local variables no longer exist, leaving only the uninitialized
instance variables.
7. Write a main method to test your Cereal class by implementing multiple instances
of Cereal objects. This program should include lines instantiating Cereal objects.
6 AP Computer Science A Student Lab Handout
Data Lab: Designing and Implementing a Custom Class – Teacher Notes
Check Your Understanding
8. Given your class design, determine one additional question that you can answer
without making any changes to [Link].
9. Identify one additional question that can be answered from the given data that you
are not able to answer based on your implementation of [Link].
10. What modification could you make in order to answer this question?
AP Computer Science A Student Lab Handout 7
Name:
Date:
ACTIVITY 3
Putting It All Together
Existing code in the form of libraries is incredibly useful and a powerful aspect of
object-oriented programming. Beyond the standard Java library, users around the
world have created and published libraries to perform countless tasks. One such
library, which you will be using in this activity and the one that follows, is the Sinbad
library. This library allows you to create a Java program that can connect to a data
source, read in data, and then process this data. The goal of this activity is to provide
practice working with the Sinbad library. Before beginning, ensure that you have set
up your IDE appropriately based on instructions from your teacher.
1. Run the main method in the Welcome01 class and provide the location and
temperature that are printed.
2. Go to the following link, [Link] and find the
four-character code for an additional location. To find the code, you first must select
the state or territory from the drop-down box shown here.
From the resulting list, choose a four-character code and modify the main method in
Welcome01 to pull information from this location instead. Provide the four-character
code here.
Then write what is displayed when running your main method with this new code.
Share your results with a partner.
AP Computer Science A Student Lab Handout 9
Data Lab: Putting It All Together
Once you have verified that the Sinbad library is installed correctly, you will work
through the “Fetching Objects” tutorial found at [Link]
blob/master/tutorials/java/[Link].
3. Using the location from the previous question, modify Welcome02_Object.java
that you completed in the tutorial to create a third Observation object for your
identified location, and then write the code to determine the coldest location between
all three Observation objects.
Next, you will work through the “Arrays and Lists of Objects” tutorial found at
[Link]
4. How many weather station objects are in your state? ________________
5. What is another way you could filter weather stations?
6. Modify [Link] and Welcome03_List to filter based on latitude,
showing the weather station that is furthest south. Do not remove existing code that
sorts weather stations based on state. What is the southernmost weather station
you found?
Tips
In order to manage large amounts of data or complex relationships in data, it
is helpful to group the data together in such a way using a single variable
that refers to a location capable of storing multiple items rather than a single
item. If the variable name holds multiple items, more information (an index) is
needed to know which specific value is being accessed.
The iterative statement can be used to access every element starting at the
beginning and moving to the last element. It has a specific structure and can
be used to take the place of repetitive code, reducing the amount of code
written and also the potential for errors. When elements are inserted or deleted
from an ArrayList, the loop counter needs to be adjusted in order to prevent
skipping an element or trying to access elements that no longer exist.
This structure can be modified to traverse the elements in different ways
such as from the end moving to the beginning or skipping certain elements.
In addition to parameters and local variables declared in a method, a method
always has access to any instance variables that are declared within the
enclosing class. These instance variables are often required to complete the
10 AP Computer Science A Student Lab Handout
Data Lab: Putting It All Together
goal of the method. If any of the available variables are objects (reference
data), then those objects may have their own methods, variables, and
constants that would be accessible within the given method as well.
Check Your Understanding
With a partner, answer and discuss the following questions.
7. What is an additional question that can be answered about weather stations or
observations based on the code that you wrote?
8. How much additional code would it take to answer this question?
AP Computer Science A Student Lab Handout 11
Name:
Date:
ACTIVITY 4
Open-Ended Activity
This open-ended activity requires you to develop a program on a topic that interests you.
As a class, spend a few minutes reviewing the requirements of the open-ended activity.
Requirements:
§ Formulate a question you would like to answer
§ Identify a data set that will help determine the answer to your question
§ Create a class to model one entry of the identified data set
§ Write a program with a main method to read the data from the identified data set into
your program
§ Utilize an array or ArrayList and the created class to store data that has been read
§ Write code to process the data and determine an answer to the identified question
In addition, review the provided rubric/scoring guidelines so that you understand what
you will be expected to explain once you are done completing your program.
It is strongly recommended that the implementation of the program involve collaboration
with another student. Your selected program can be anything that you choose that
meets the requirement and allows you to demonstrate your understanding.
Before beginning, make sure that you understand the expectations for the activity.
§ Who will you be working with? Are you allowed to work with a partner? In a group of
three or four?
§ Among the members of your group (or with your partner), how will the implementation
be completed?
§ If you will be using pair programming, will your teacher be instructing you when to
switch driver and navigator, or is this something that you need to keep track of?
§ What should you do if your group/pair is stuck? Does your teacher want you to come
straight to them? Are you allowed to ask another group?
Tip
For groups that choose to traverse multiple structures simultaneously:
When traversing multiple data structures simultaneously, structures might
not be the same size and loop bounds must be adjusted to make sure that
only locations that are valid in all structures are accessed.
AP Computer Science A Student Lab Handout 13
Data Lab: Open-Ended Activity
Check Your Understanding
Once your program has been implemented and tested, you should answer the
following questions on your own:
1. State the question you chose to answer and why you chose this question.
2. Describe the data set that you chose to help answer this question, and the process
used to find the data set.
3. Describe the development process used in the completion of this project.
4. Describe the class used to represent entries in the identified data set, and why the
specific instance variables were chosen.
5. Provide the code segment where data is being processed and describe how the
data was processed in order to answer the identified question. Note that data must be
stored in an array or ArrayList in order to earn full credit.
14 AP Computer Science A Student Lab Handout