Mr. Rogers AP Computer Science A - First Quarter Objectives

 

Essential Question: How do you write a program?

Chapter 1 & 2: Software Basics

(AP Computer Science Standard: II Program Implementation, III Program Analysis, VI Computing in Context)

First Day

Introduction - Hand out syllabus

  1. Use console output (System.out.println)

Programming Assignment 1: Write a program that outputs "Hello World" to the screen.

  1. Define the term debugging.
  2. Define compiling error and describe a way to cause one.

Deliberately delete a ";" from the above program and note the error message. Deliberately alter other elements of the program to see what happens

Second Day

  1. Explain what compilers and interpreters do and why compiled code generally runs faster.
  2. Describe how Java's source code is compiled to byte code and then interpreted by the Java virtual machine work together.
  3. Give examples of different operating systems and explain why the Java virtual machine is needed.
  4. Define encapsulation and information hiding

Programming Assignment 2: Write a program that inputs (your name) and (your age) on the command line and outputs "Hello (your name) you are (your age) years old".

  1. Define run-time error and describe a way to cause one. The program compiles but does not run. Usually throws an exception.

Deliberately cause a run time error in  the above program and note what happens.

  1. Define the term iteration and describe a way to do it--example: pounding a nail, "for loop"

Programming Assignment 3: Modify Programming Assignment 2 with a "for loop" so that the message repeats itself 10 times. once the program is running, modify it so that it has an infinite loop and see what happens when you run it.

Sample code:

for (int x = 0; x < 10; x ++) {

    //Lines of code

}

  1. Define logic error and describe a way to cause one. The program compiles and runs but does not run correctly. This is the worst type of problem because it gives no error messages or exceptions.
  2. Be aware that while a program can branch to a different part of the code or go round-and-round in a loop, it otherwise executes sequentially from the top to the bottom for a given method.
  3. Describe one of the key strategies in the creation of complex software: functional decomposition (breaking down an overwhelmingly complex task into smaller doable tasks). Note: Creating a a software project of even a few hundred lines of code rapidly becomes complex if not overwhelming. The key to success is to take baby steps.
  4. Complete the first chapter of the AP Computer science case study GridWorld.

Note: Mastery of the case study often means the difference between a 4 and 5 on the AP Exam. Start early and give it priority!

  1. Know how the squares or cells in GridWorld are numbered.

Assignments: The below assignments are to be completed within the first 10 days of school.

All Homefun (sometimes improperly referred to as homework)  assignments are to be turned in on the day of the test. They are to be stapled to the back of the test paper. Late Humefun will not be accepted.

Homefun (summative/formative assessment):

GridWorld: Read Section 1; Do exercises 1-4. Note: you will not understand all of the terminology. Don't worry: your not supposed to. However, you'll find that if you don't let the jargon bother you, you can muddle through. In programming, muddling is a highly valued art. In the past, a good working knowledge of the case study has often made the difference between a 4 and a 5 on the AP Exam.

 

Each Programming assignment is to be set up in a separate project and placed on your student virtual hard drive on or before the day of the unit test

Programming Assignment 4: Write a program that receives three input characters via command line input and outputs your printed initials in large size (at least 2 inches high) using the 3 input characters stored in string variables. Note: you need to write the initials on graph paper in order to know how many spaces to put between the string variables.

Example 1:

Input: "T", "K", "R"

Output:

T T T T T   K     K   R R R R
    T       K   K     R     R
    T       K K       R R R R
    T       K   K     R   R  
    T       K     K   R     R

Example 2:

Input: "X", "Y", "Z"

Output:

X X X X X   Y     Y   Z Z Z Z
    X       Y   Y     Z     Z
    X       Y Y       Z Z Z Z
    X       Y   Y     Z   Z  
    X       Y     Y   Z     Z

Programming Assignment 5: Write a program that uses "for loops" to output a quilt-like pattern out of characters. It should have at least 2 different patches, repeated twice.

example:

X X X
X X X
X X X
0  0  0
0  0  0
0  0  0
X X X
X X X
X X X
0  0  0
0  0  0
0  0  0

Read Sections: 2.1 to 2.3  

Summative Assessment: Unit Test Chap 1 & 2 Objectives 1-14

Essential Question: What is a computer?

    Chapter 1 & 2 (continued): Hardware Basics

    (AP Computer Science Standard: VI Computing in Context)

  1. Define the terms:
  1. State the basic types of gates and give logic tables for each. http://scitec.uwichill.edu.bb/cmp/online/P10F/logic_gates2.htm

3 Person Group Assignment:

  1. Create a digital circuit using gates that describes an activity (must use both "and" as well as "or" gates, 5 gates minimum).
  2. Create an xor gate from "not", "and" and "or" gates.
  1. Correctly identify and describe the functions of the following components.

Outline the architecture of the central processing unit (CPU) and the functions of the arithmetic logic unit (ALU) and the control unit (CU) and the registers within the CPU.

Explain the machine instruction cycle.

Describe the main functions of an
operating system.

     

  1. Describe the function of ROM and the BIOS.
  2. Describe the function of a UPS (uninterrupted power supply, battery back up).
  3. Name the 2 most common I/O devices. (keyboard, monitor)
  4. Compare single user computer systems with Networks.

Read Sections: 1.1 to 1.4


 

Essential Question: How are numbers, letters, and colors represented in computers?

Chapter 1 & 2 (continued): How Information is Represented

  1. Describe the following number systems: binary, decimal, and hexadecimal (see How to Count to 1,023 on Your Fingers).
  2. Convert binary to decimal numbers.
  3. Convert binary to hexadecimal numbers.  (see Hex Headquarters)
  4. Convert hexadecimal to binary.
  5. Convert hexadecimal to decimal numbers.
  6. State how characters are represented inside computers and give the name of the 2 types of code.

 

Code Type Bytes Possible Characters
ASCII 1 256
Unicode (used in Java) 2 65,536
  1. Describe how colors are commonly represented.
  2. Given a quantity of bits specify the largest number which can be represented.

max # = (2n - 1)

  1. Given a number of bits specify the largest number of objects or colors which can be specified. max # of objects = 2n
Read Sections: 1.5 to 1.7
 
Homefun (summative/formative assessment):
Complete the Number Conversion and Unicode worksheet

 

Essential Question: What is the most important part of a piece of software's life cycle?
    Chapter 1 & 2 (continued): Software Design Basics

    (AP Computer Science Standard: I Object-Oriented Program Design)

  1. Use the two major computer program development tools.
  1. Use a flow chart to represent algorithms containing a loop
  • multiplication using only addition-- x∙y → Input x and y. Set product = 0 and add x to it y times. Output product.
  • division using only subtraction-- x/y → Input x and y. Set counter = 0. Subtract y from x and add one to counter. Repeat the process until x < 0.  The quotient = (final counter value) - 1. The remainder = ( final x value) + y. Output the quotient and remainder.

 

Example: Flow chart for Hello <name> program that outputs 3 times using a for loop.

  1. Contrast procedural and object oriented programming. (Note: Java is object oriented.)
  1. List and explain the 6 phases of the Software System Life Cycle. Note that knowledge of the system's subject is often as important as knowledge of computing.
    • Analysis--identifying the needs to be addressed by the system.
    • Design--specifying the systems (both hardware and software) required to address the needs identified in the analysis step.
    • Coding--creating the actual code
    • Testing/verification--gone awry ... lobster people !
    • Maintenance--fixing problems and responding to customer needs after the software is released to the customer.
    • Obsolescence--updating the software with a new version.

Prediction

In the near term future there will not be enough people with Computer Science degrees. The solution: Liberal Arts, Biology, Business, and other types of majors with any background in computing will be used to compensate. These people will have an increased number of job opportunities.

  1. Describe top-down design.
  2. Describe key strategies in the test phase.
  1. State the type of program used for delivering Java programs over the internet.
  2. Write a simple applet. (See AppletDemo Code. Run AppletDemo)

Read Chap. 2

 

Homefun (summative/formative assessment):

Exercises 1, 6, p. 38

Use a flow chart to represent algorithms containing a loop

  • multiplication using only addition
  • division using only subtraction

Programming Assignments:

Summative Assessment: Test Chap 1 & 2 Objectives 1-24--come prepared to write an applet on paper


Chapter 3: Introduction to Classes & Objects

(AP Computer Science Standard: I Object-Oriented Program Design, II Program Implementation)

 

Essential Question: If a program has several million lines of code and is being worked on by people around the globe 24 hours a day, how do you prevent one part of the code from interfering with the other parts?
 
Class and Object  Features in Java
  1. Correctly use the following terms and be able to identify and use them in a program (reference: Oracle Sun Developer Network Glossary):
  • API (Applications Programming Interface) -the ultimate source of information for reusable Java code.
  • packages - a related group of classes or interfaces

Classes: ClassRoomExample, People

  • instance methods When used by a different class it is called with an instance of its home class, example: bob.getsOlder ( ). bob is an instance or object of the class containing the getsOlder method.

  • Static methods declared static in the method's 1st line of code. When used by a different class it is called with name of its home class, example Math.cos (5.9). Math is the class name. cos ( ) is a method inside the Math class. 5.9 is a double being passed to the cos method as an argument.

  • parameters--give data types. Parameters are contained in method's header and specify the arguments to be used when calling a method. example: computeTax (double income, int age). income and age are both parameters.

  • arguments--used when calling a method. example: computeTax (dollars, years). dollars and years are both arguments. Note: the data type of the argument must mach that of the parameter, but the name does not need to match.

 

Programming Assignment (summative/formative assessment): Complete the Pumpkin Project as specified in the Farm class using the Pumpkin class.

 

Essential Question: How can you implement encapsulation and information hiding in ways that reduce the amount of source code?

Inheritance

  1. Explain how inheritance (uses the key word extends) works and why it is used.

    • superclass

    • subclass--"is-a" relationship (descendent relationship) examples: a car (subclass) is-a vehicle (superclass). A bus is-a vehicle. A truck is-a vehicle. The reverse is not true, for example, a vehicle is not a truck

 

Interfaces: Grades
  1. Explain the "has-a" relationship. (Used for defining fields)

client, characteristic, or component relationship examples: A car has a motor. A store has a customer. A girl has a name. A class has a field.

  1. Use "super" to call public methods of a super class from within a subclass.

super.calculateHours ( double starTime, double stopTime);

  1. Be aware that private fields in a superclass cannot be accessed in subclasses, not even using a get method.

  2. Access a superclass's protected fields from a subclass by calling a get method for the field.

example : super.getWeight ( );  // returns the value of the protected
                                                  // weight field found in the 
                                                  // superclass
  1. Explain the term "primitive data types" and give examples. These are data types that are fully defined within the Java language. a primitive data type will have a fixed memory allocation (in other words number of bytes used for storage of the value).

examples: int, char, double

  1. Name four classes contained in the java.lang package which are automatically imported into your java programs.

 
Read Chap. 3; Computational Thinking

 

Homefun (summative/formative assessment):
  1. Write brief definitions for the terms in objectives 1 and 2 that are highlighted as follows: Term. Use the textbook and the Sun Developer Network Glossary.

     

  2. Next find a program(s) with examples of each of the terms in objectives 1 & 2 and identify them. You may use programs from the book, the internet, or ones you've written yourself. You may work as a group on part 2.

Programming Assignment: Exercise 9, 10, 12

Programming Assignment: Write an applet with a Human class, Student class, School class and a Grades interface. The Human class will have a field for IQ and a constructor that can give it a unique value. The student class will have fields for name, test1, test2, and average grade. It will extend the Human class. The student class constructor will have parameters for initializing all the fields except average grade. The grades interface will have a method for calculating average grades. The student class will make use of the method that calculates average grade from the grades interface. The school is to have 3 students created in the school class and is to output all the school's information in a table as follow shown in the following example:

Name          IQ        Test 1       Test 2          Average Grade

Bob            100         50            100                   75

Jane           110         90            100                   95

Martha        120         80              90                   85

 

Summative Assessment: Test Chap 3 Objectives 1- 8

Relevance: Knowledge of object oriented programs (OOPs) is a highly useful employment skill The degree breakdown for computer/math scientists

 


 
Chapter 4: Algorithms

(AP Computer Science Standard: III Program Analysis)

 
Essential Question: How does an algorithm compare to a mathematical model in physics or engineering?

 
What is an Algorithm
  1. Define the term algorithm.
  2. Correctly use recursion. Read the Barron's book write up on recursion. Click here for a simple example of recursion. Relevance: If you can do recursions you can learn to do anything in Comp Sci.
    • Must call itself within the method
    • Must alter one or more of its arguments each time it calls itself.
    • Must have a means of stopping itself based on the modified argument(s)

    • Stores calculated values in a stack and evaluates them after the recursion stops.

Programming Assignment: Write a program that inputs an integer n using command line input and uses it to calculate n factorial using recursion.
 
Programming Assignment: Write an application that finds and outputs Pi using recursion and the following series: Click here for 3 examples of recursion.

(Pi 2)/6 = 1 + 1/22 + 1/32 + ... + 1/n2

Input the number of times the recursion should run using command line input.

 

  1. Determine the number of iterations a given recursion will have.
  2. Define list in abstract terms. an abstract data structure that implements an ordered collection of values, where the same value may occur more than once. The simplest form of list is an array.
  1. Define traversal.
  2. The process of visiting (examining and/or updating) each node or item in a list.
  3. Compare sequential to binary search.
    Note: O(----) as shown below is called big O notation and indicates how run time will increase for as the amount of data items = n increases.
  • sequential: examines each item in a list in order until it finds the one it's searching for. O(n) run time increases proportional to the number of items searched = n.
  • binary: list must be sorted. Uses a divide and conquer technique (20 questions). O(log n) run time increases proportional to the logrithm of the number of items searched = n.
n 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00
log n 0.30 0.48 0.60 0.70 0.78 0.85 0.90 0.95 1.00
 
Read Chap. 4; Algorithms Should Mind Your Business, How To Think: Algorithmic Thinking, Read the Recursion section of the Barron's book. Read and study yet another Mr. Rogers' recursion example.

 

Homefun (summative/formative assessment):
    1) Exercises 1,  7, 9,
    2) Based on the reading assignments, write a 1/2 to one page paper explaining what algorithmic thinking is and how it differs from mathematical thinking.
Programming Assignment: Exercise 10
 
Summative Assessment: Test Chap 4 Objectives 1- 6
 
Relevance: Prior to the second half of the 21st century, the mathematical model particularly in physics was king as a method of predicting outcomes and solving problems. However, there are many problems which can only be solved with algorithms especially in the less mathematical sciences. Even in physics algorithms are required for solving chaos related problems.

 


 

Essential Question: What's the difference between style and syntax?

Chap. 5: Java Syntax and Style

(AP Computer Science Standard: II Program Implementation, III Program Analysis)

  1. Correctly use the three forms of comments:

  1. Identify reserved words (p. 107).

  2. Correctly use the naming conventions for classes, methods, and fields.

  1. Correctly indent programs.

Homefun (summative/formative assessment):
Read Chap. 5; Princeton professor foresees computer science revolution
Exercises 3, 4, 5, 7, 8, 10

 

Programming Assignment: Lab 5.6

 

Relevance: A program won't run without proper syntax. Proper style makes the code readable so that it can be modified and maintained.

 
Essential Question: Why did you learn to find remainders in grade school instead of going straight to long division ?

 

Chapter 6: Data Types, Variables, and Arithmetic

(AP Computer Science Standard: II Program Implementation, III Program Analysis)

  1. Understand the meaning and use of the equal sign in Java.

  1. Correctly declare fields and local variables.

  2. Correctly initialize fields, local variable, and parameters.

  3. State the default values used for initializing fields.

  1. State the default value used for initializing local variables. (there isn't one)

  2. State the eight types of primitive data types and their sizes in bytes. (p. 129)

  3. Explain why the largest size of an integer or long variable can be a major issue. The size is finite and if the size is exceeded the program will not work.

Data Type Max size
int   slightly over 2.1 x 10 9
long   slightly over 9.2  x 10 18
double   1.8 x 10 308
  1. Explain the limitations of precision on floating point data types and why these limitations can produce round-off errors. Unlike a short, integer, or long, a floating point number is not exact. It has a limited number of significant figures. Repetitive calculations can produce significant rounding errors.

  2. State the primitive data types which do not have a true zero and explain why this can be a problem. double and float

  3. Correctly Use:

  1. Understand the term scope (p. 133). Note: the concept of scope is incredibly important to programming in Java. You must consider it whenever you create a variable. As a matter of style, variables should be declared at the top limit of their scope.

  1. Correctly convert numbers and objects into strings and explain why objects need special attention. (An object may have multiple variables or fields of different data types associated with them, hence the output has to be defined in order to understand how it should be done.)

Homefun (summative/formative assessment): read Sections 6.1 to 6.5; Exercises 1- 7 p.146-147

 

  1. Use literal constants as either int or doubles (Example: int: 2, double: 2.0).

  2. Correctly use the order of operation for arithmetic.

    1. parentheses

    2. division, multiplication, modulus

    3. addition, subtraction

  3. Perform division using integers and doubles.

Note: integer division truncates the decimal portion of a number. It does NOT round numbers. Mixed division of integers and doubles upgrades the answer to a double (this is called autoboxing).

Examples:
division of integers: 1 / 2       yields 0
division of doubles: 1.0 / 2.0 yields 0.5
mixed division:         1 / 2.0    yields 0.5,  1.0 / 2    yields 0.5  

 

  1. Truncate and round numbers using integer division.

Examples:
1/2 rounded to nearest whole number
((1*10) / 2 + 5) / 10  yields 1

 

y/x  rounded to nearest whole number
((y*10) / x + 5) / 10
  1. Cast variables.

Example:
int a, b;
double c;
c = (double) a / (double) b;
  1. Correctly use various arithmetic operators including:

  • modulus (%) returns remainder: 1 = 5 % 2

  • compound assignment operators (/=, +=, -=, *=, %=)

  • increment/decrement (y++, ++y, y--, --y)

 

Modulus Examples

1 = 1 % 3

2 = 2 % 3

0 = 3 % 3

1 = 4 % 3

2 = 5 % 3

0 = 6 % 3

 
Homefun (summative/formative assessment): Read Sections 6.6 to 6.10; Exercises 8, 10, 11 p.147-148

 

Programming Assignment: Lab 6.10, Exercises 12, 13 p.148

 

Programming Assignment: Write a program which uses command line input to input a single dimension in centimeters. Use this dimension to calculate and output the surface area and volume of a cube, sphere, and cylinder along with the correct units. The radius and height of the cylinder are equal to the dimension. Use a separate method for each calculation.

 

Relevance: Handling massive numbers of transactions involving money without losing anything to rounding errors is a major issue for international finance and businesses.

 
Essential Question: How does a progressive income tax system work and is it a good idea?

Note: with a progressive income tax, when a higher rate is triggered the taxpayer only pays the higher rate on income above the amount that triggers the higher rate.

Tax code program:

Input: Using the command line input income in dollars. (This needs to be changed to cents inside the program.)

Output:

NTR = (taxDue) / (income) *100

Description: The program will round any tenths of a cent upward. "If" statements are not allowed. The program will use only algorithms to calculate taxes. It will use the following progressive tax table:

 
Income ($) Tax Rate Comments
        0 to 19,999.99  00 %

This part of income is never taxed

20,000 to 29,999.99 25 % Only income above $19,999.99 is taxed at 25%
30,000 +                    35 % Only Income above $29,999.99 is taxed at 35%. Note this is an additional 10% above the 25% tax that kicks in at $29,999.99.

 
Homefun (summative/formative assessment):

Practice Test

 

Summative Assessment: Test Chap 5 & 6 Objectives 1-22