|
Mr. Rogers AP Computer Science A - First Quarter Objectives |
| Syllabus | 1st Quarter | 2nd Quarter | 3rd Quarter | 4th Quarter |
|
| 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
Programming Assignment 1: Write a program that outputs "Hello World" to the screen.
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
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".
Deliberately cause a run time error in the above program and note what happens.
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
}
- Go to the College board site and download the... Student Manual (.pdf/630KB)
- Download the................................................................. Code (.zip/238KB)
- Download and follow the............................................. Installation Guide (.pdf/172KB) for Bluej
Assignments: The below assignments are to be completed within the first 10 days of school.
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.
Programming Assignment 4: Write a program which 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
Read Sections: 2.1 to 2.3
| Essential Question: What is a computer? |
Chapter 1 & 2 (continued): Hardware Basics
(AP Computer Science Standard: VI Computing in Context)
- bit--a binary digit
- byte--8 bits
- kilobyte--old = 210, new = 1,000 bytes
- megabyte--old = 220, new = 1,000,000 bytes
- gigabyte--old = 230, new = 1,000,000,000 bytes
- not
- and
- or
- xor (can be made from the 3 gates shown above)
3 Person Group Assignment:
- Create a digital circuit using gates that describes an activity (must use both "and" as well as "or" gates, 5 gates minimum).
- Create an xor gate from "not", "and" and "or" gates.
- stand-alone applications (single user)--word processors, spread sheets, etc.
- information sharing and communication--various mark up languages such as html (used on web pages),
- distributed software--applets (use java language), java scripts (not java!), server side software, etc
- cluster computing--Beowulf systems, SETI
Read Sections: 1.1 to 1.4
Summative Assessment: Test Chap 1 & 2 Objectives 1-20
| Essential Question: How are numbers, letters, and colors represented in computers? |
Chapter 1 & 2 (continued): How Information is Represented
- Write a program that converts a lower case character to upper and vice versa.
- State which comes first upper or lower case numbers.
Code Type Bytes Possible Characters ASCII 1 256 Unicode (used in Java) 2 65,536
| Essential Question: What is the most important part of a piece of software's life cycle? |
(AP Computer Science Standard: I Object-Oriented Program Design)
- Pseudo code
- Flow Charts--use PowerPoint
- 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.
|
|
- isolation testing--classes and libraries are tested separately
- boundary condition testing--boundaries are identified and used for generating test data.
- integration testing--all of the software's components are combined and tested as a unit
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:
- Exercises 14, (15 &16) in same program
- Write a really cool applet that moves three or more different types of graphic elements around the screen while changing their color and size. Output a stationary title for the applet in the center of the screen so that it is never obscured by the moving elements. The elements are to look like they move under the writing. Use a timer to control the speed of the animation.
Summative Assessment: Test Chap 1 & 2 Objectives 1-18--come prepared to write an applet on paper
(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? |
Correctly use the following terms and be able to identify and use them in a program:
API (Applications Programming Interface)--the ultimate source of information for reusable Java code.
packages
fully-qualified name - Library.package.class example: javax.swing.JButton (means JButton class)
wild card - *
instance
object
methods--the name of the method is always followed by a set of parentheses. example: calculateCost ( )
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.
constructor (called with new operator when the object is created and allocated RAM) Must have the same name as the class.
field (primitives or objects) declared at the top of the class
static--static methods & fields called with the name of their class
event
listener
interface--uses the implements keyword, often used for adding listeners.
classes--their names are always capitalized
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
|
|
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.
Use "super" to call public methods of a super class from within a subclass.
super.calculateHours ( double starTime, double stopTime);
Be aware that private fields in a superclass cannot be accessed in subclasses.
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
Explain the term "primitive data types" and give examples.
examples: int, char, double
Name four classes contained in the java.lang package which is automatically imported into your java programs.
System
Math
Object
String
- Write brief definitions for the above terms in objectives 1 and 2. Use the textbook and the Sun Developer Network Glossary.
- Next find a program(s) with examples of each 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 Student class, a School class and a Grades interface. The student class will have fields for name, test1, test2, and average grade. It's 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 Test 1 Test 2 Average Grade
Bob 50 100 75
Jane 90 100 95
Martha 80 90 85
Summative Assessment: Test Chap 3 Objectives 1- 8
(AP Computer Science Standard: III Program Analysis)
| Essential Question: How does an algorithm compare to a mathematical model in physics or engineering? |
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.
- items numbered
- method for accessing the i th item is defined
- 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
| 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)
Correctly use the three forms of comments:
// Single line comment
/* One or more lines of comments*/
/** Javadoc comments*/
Identify reserved words (p. 107).
Correctly use the naming conventions for classes, methods, and fields.
Capitalize the first letter of classes but not methods or fields.
The first character must be a letter & have no spaces in it.
Names can include letters, numbers or the underscore_.
Names should be descriptive.
Method names = verbs, field = nouns
Constants use all capitals.
Correctly indent programs.
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)
Understand the meaning and use of the equal sign in Java.
Can have only one field or variable on the left side
Means "replaced by", not equals
Correctly declare fields and local variables.
Correctly initialize fields, local variable, and parameters.
State the default values used for initializing fields.
numeric types: 0
objects: null
State the default value used for initializing local variables. (there isn't one)
State the eight types of primitive data types and their sizes in bytes. (p. 129)
Explain why the largest size of an integer or long variable can be a major issue.
Explain the limitations of precision on floating point data types and why these limitations can produce round-off errors.
State the primitive data types which do not have a true zero and explain why this can be a problem.
Correctly Use:
literal constant - letters in single quotes and numbers
symbolic constant - declared and initialized using final
escape sequences (p.131, \n newline, \t tab, \\slash, etc.)
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.
inside the { } of a class
inside the { } of a method
inside the { } of a loop, if, else statement, or any other set of {}
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.)
Concatenate to an empty string. Example: System.out.print ("" + 6);
Use toString method for converting objects to strings (This method outputs the class name and memory location. To output something more meaningful it has to be overridden.)
Homefun (summative/formative assessment): read Sections 6.1 to 6.5; Exercises 1- 7 p.146-147
Use literal constants as either int or doubles (Example: int: 2, double: 2.0).
Correctly use the order of operation for arithmetic.
parentheses
division, multiplication, modulus
addition, subtraction
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
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
Cast variables.
- Example:
- int a, b;
- double c;
- c = (double) a / (double) b;
|
|
|||||
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? |
Tax code program:
Input: Using the command line input income in dollars. (This needs to be changed to cents inside the program.)
Output:
Taxable income in dollars
Tax due in dollars (round tenths of cents upward)
Nominal tax rate in % of income
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): |
|
Summative Assessment: Test Chap 5 & 6 Objectives 1-22