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
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
}
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!
- 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 BluejB
- (column number, row number)
- column numbers start with 0 on the left and increase as the columns go to the right.
- row numbers start with 0 at the top and increase as the rows go downward.
- the cell in the upper left hand quarter is labeled 0, 0
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)
- 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.
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.
- 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
Essential Question: How are numbers, letters, and colors represented in computers? |
Chapter 1 & 2 (continued): How Information is Represented
- State which comes first upper or lower case numbers. Upper case comes first.
- Write a program that converts a lower case character to upper and vice versa and converts a character to the Unicode number used to represent it.
Code Type Bytes Possible Characters ASCII 1 256 Unicode (used in Java) 2 65,536
max # = (2n - 1)
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--English language-like representation of code that looks code-like and describes the detailed operation of a program. Pseudo code does not follow the syntax of any particular programming language.
- Flow Charts--use PowerPoint
|
|
|
|
- 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-24--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? |
|
|
fully-qualified name - Library.package.class example: javax.swing.JButton (means JButton class)
wild card - The wild card or * causes all the classes of a package to be included in a program. example: import javax.swing.*
instance - a data record with unique values stored for each of the non-static fields in a class.
object - see instance above.
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 - are methods that establish the initial values of fields. Called with new operator when the object is created and allocated RAM. Must have the same name as the class.
field - a non-static data member (primitives or objects) of a class declared within the class (normally at the top) but not within a method. Has a specific value for each instance.
static -
A Java keyword used to define a variable as a class variable or a method as a class method.
Static methods & variables are called with the name of their class. Static variables are declared in a class but not in a method similar to fields. Unlike fields, static variables can store only a single value regardless of the number of instances of the class.event - starts or stops a procedure that is defined in a listener. Events are created by objects such as buttons, sliders, timers, etc.
listener - listeners are methods that respond to events. Programs using listeners must implement the appropriate interface that specifies the listener.
interface - uses the implements keyword. Interfaces are used for a variety of tasks including 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, not even using a get method.
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. 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
Name four classes contained in the java.lang package which are automatically imported into your java programs.
System
Math
Object
String
- 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.
- 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
(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. 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
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.
State the primitive data types which do not have a true zero and explain why this can be a problem. double and float
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? |
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:
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