Aspirations in Computing Award (for women, genderqueer, or non-binary students with strong interests in computer technology)
Course Workbook (Work in Progress)
CodeHS Gitbook (Specifically the "Basic Java" and "Methods" units)
CSAwesome (Specifically units 1-4)
Princeton's Interdisciplinary Approach to Computer Science
Think Java Textbook : HTML Version PDF Version Trinket Version
Study Material: Library Fiveable
Youtube - Math & Comps
Vocab - Virginia CS101 Vocab
Playlist - Physical Memory Models
PracticeIt - CS Washington (Specifically Chapters 7-10, 12-13) CodeStepByStep
Downloads: Eclipse Java Developer Download JDK Download
Online Java Compiler (Code in browser) - Online GDB Â Â CodeHS
The following terms are ones you should be very familiar with at the end of this unit.
Computer Science - The art of solving problems with a computer
Programming - Writing out a sequence of commands that a computer understands and can execute.
Computer Program - Instructions for a computer to follow (like a recipe, or instructions to build Ikea furniture)
Problem Solving - Creating a solution to a problem
Binary - 1's and 0's.
Logic - the process that solving a problem (similar to algorithm, but less concrete)
Algorithm - the specific sequence of steps that generates a solution to a problem. Algorithms must be repeatable (doing the same task under the same circumstances should produce the same/expected results)
Hardware
Software
System Software - Operating System - Software that manages the computer (Windows, Linux, MacOS)
Application Software - Software that completes a specific task (calculator, web browser, game, etc)
Youtube - TechPrep - What is Computer Science?
Slides - What is Computer Science (Guided Notes)
Video - CS is Everywhere (Video is also in Slides)
Reading - Think Java - What is Computer Science
Slides - CS Careers
Worksheet - Career Exploration
Slides - Communication & Binary (Guided Notes)
Worksheet - Binary Name
Binary Resources:
CSAwesome (Access through Canvas - "CSAwesome - Chapter 1 Readings")
Getting Started
Preface
Java Development Environments
Growth Mindset & Pair Programming
Pretest for the AP CS A Exam
Survey
The following terms are ones you should be very familiar with at the end of this unit.
Statement - A single command.
Comment - Text in a program that will not be executed by the compiler (side notes for the programmer, not the computer)
Method/Function - A chunk of related commands that are given a single name. Instead of saying "A^2 + B^2 = C^2" I can just say "The Pythagorean Theorem".
Virtual Machine - A program that acts like another machine/Operating System.
Bug - a problem/error in your code/algorithm. There are 3 types of bugs - Syntax, Runtime, and Logical/Semantic.
Syntax Error - A bug caused by not following the rules of the programming language. Your program won't run at all.
Runtime Error - A bug caused by doing something unexpected in a program (like dividing by 0, or trying to convert "Hello" into a number). Program crashes mid-run
Logical/Semantic Error - A bug caused by not getting the correct output. Example: "Hello "+2+2 = "Hello22", not "Hello4". This is called a logical error or a semantic error because your logic is wrong or your logic doesn't match the computer's logic. Your code is being misinterpreted by the computer.
Debugging - Trying to find your errors and fix them.
Slides - What does it all mean (Guided Notes)
Slides - Software Solutions 01
Slides - Programming Basics (Guided Notes)
Youtube: Mr. Joyce's Basic Outputs - Useful reference for those who need to watch someone program
Worksheet - Strings & Escape Sequences
Practice - PracticeIt - Intro to Java Programming
Worksheet - Error Fixing
Challenges
Text Output
Rocket (Easy)
Park (Medium)
Shrek Coding Challenge (Hard)
Extra Resources:
Youtube: Mr. Joyce's Basic Operations
Formatting Doubles - https://langintro.com/comsc075/formatting_output.html
Potential Challenges:
Convert Time: Hours & Minutes --> Minutes
Convert Time: Minutes --> Hours & Minutes (Modulus)
Momentum: mass * velocity
Kinetic Energy: KE = 1/2 m*v*v
Paycheck Calculator: normal hours, overtime hours, hourly wage
Coin total: #quarters, #dimes, #nickles, #pennies
Mrs. Gray's Resources - the Mod Game (Teacher resource - Login Required)
The Mod Game is similar to "Rock, Paper, Scissors", but is played with 3 people, each assigned the value 0, 1, or 2.Â
Instead of picking Rock, Paper, or Scissors, students pick a # from 0 to 5. Once shown, students add their values together, divide by 3, and calculate the remainder (the modulus/mod).
The winner is the person assigned the number that matches the modulated result.
Algorithm:
3 players
each is assigned the # 0, 1, or 2 (identifier).
Repeat the following until some condition is met (first to 3 points, for example)
Similar to "Rock, Paper, Scissors", students pick a value, but their value must be a random #, 0-5.
When ready, all students show their value
Add all values
Modulate by 3 (Remainder after dividing by 3) - this gives you a 0, 1, or 2 value
Whoever's assigned # (identifier) matches the modulated result gets a point.
Below is a visual to help you understand functions.
I highly encourage students to write this down on a piece of paper and have this handy as a reference.
Slides - Strings & Methods (Guided Notes)
Worksheet - Creating Methods
The following is code that helps to make numbers look good in the following ways:
Adding trailing 0's so that #'s have a consistent # of places after a decimal
Rounding #'s a certain # of places after a decimal
Padding #'s with leading white space (plus trailing 0's or rounding) so that #'s take up the same amount of space (alignment)
The following code is an example of how students can create functions in a special class (a library) that can be called from other classes.
In order to call any functions from this class you have to ensure the following:
The class is in the same package/project as the code you're connecting to it.
You reference the name of the class followed by a "." followed by the function you want to use
MyFunctions.inputDouble("Give me a number", scan);
import java.util.Scanner;
public class MyFunctions
{
public static double inputDouble(String msg, Scanner scan)
{
System.out.println(msg);
double resp = scan.nextDouble(); scan.nextLine();
return resp;
}
public static String makePretty(double val, int place)
{
return String.format("%."+place+"f", val);
}
}
<Under Construction>
CSAwesome (Access through Canvas - "CSAwesome - Chapter 2 Reading - Objects & Functions")
Objects - Instances of Classes
Creating & Initializing Objects - Constructors
Calling Methods without Parameters
Calling Methods with Parameters
Methods that Return Values
CSAwesome (Access through Canvas - "CSAwesome - Chapter 2 Reading - Strings & Math")
CSAwesome (Access through Canvas - "CSAwesome - Chapter 2 Problems & Quiz")
Youtube: Mr. Joyce's Basic Java Input
Scanner Basics - Getting Strings
MadLibs Coding Challenge (Graded)
Scanner Basics - Other Inputs
CSAwesome - Java Swing GUI (Optional Lesson)
Equality Operators
== is equal to
!= is not equal to
Relational Operators
< Less than
> Greater than
<= Less than or equal to
>= Greater than or equal to
Logical Operators
! Not
&& AND
|| OR
Additional Resources
If
else if
else
nesting
Comparing Primitives
Comparing Strings/Objects
WordToPigLatin - Create a function which takes in a single word and converts it into pig latin
Consider creating a 2nd function called beginsWithVowel which also takes in a word and returns whether or not the word begins with a vowel.
Iterator
For Loop
While Loop
Condition
Initializer
Incrementor
Worksheet 1 - [not posted]
Worksheet 2 - [not posted]
Challenge - Ask the user for 5 numbers, print the smallest, largest, sum, and average.
Challenge - Alternating Case - go through every character in a String and capitalize it if it's @ an even index, and lowercase it if it's @ an odd index.
Challenge - Fibonacci
Challenge - Scrambled String
"As long as" loop.
"As long as the user says 'flip'"
"As long as the 2 dice aren't the same:
Use while loops when you don't know the exact # of times you'll do something
Common While Loop scenarios:
User Input Validators
This often involves "AND" and "OR" statements
Dice Games (roll 2 dice until you get doubles)
Repeat until the user says "quit" (similar to a validator)
Infinite Loops
tally problems (paired with arrays) - roll 2 dice 100,000,000 times and count how many times they sum to 2, 3, 4, ..., 10, 11, 12.
Scenarios that can be hard to tell that you should use a while loop, or that you could potentially use either.
Rock Paper Scissors - Best out of 3. How many times will you repeat? at least 2 times, maybe 3. With ties, it might be more.
List search algorithms - You could loop through every item in a list, but once you find the correct value, you should kick out.
Practice:
CSAwesome Runestone
Data Validator - Get number between 1 and 10 from the user. As long as they type something outside the range, get a different number from the user. When a valid number is written print "Nicely done" and end the program.
RollDoubles - Roll 2 dice. As long as the dice aren't doubles, roll again. Count how many rolls it takes.
Get the user's text - "Duck" or "Goose". As long as they said "Duck" get another value. When they finally type "Goose" print "Run!" and end the program.
Tipsy Timmy - Tipsy Timmy is trying to cross a bridge, but he had too much to drink. He starts in the middle of one side of the bridge. He always moves forwards, but some times he moves 1 space forward and other times he moves 1 space diagonally (left or right), potentially getting near the edge. The bridge is 11 steps wide (center of bridge + 5 steps to the left and 5 steps to the right), and 30 steps long. Can Tipsy Timmy make it across all 30 steps without falling off the edge of the bridge? Every step Tipsy Timmy randomly moved forward, forward-left, and forward-right.
Revisit the PigLatin program from the Booleans/Conditionals unit. Scan a full line of text. Try to divide the text into words and pass the words into the piglatinTranslator function.
Do Loops
Switch Statements
Breaks & Continues
Nested Loops
Before, we learned how to do basic Functions on Strings, mostly revolving around pulling substrings or basic conditionals.
Now, we're going to use loops to do something with Strings.
Go to Codingbat String-2
Work on the problems in here - 1-by-1.
Save the code you write in eclipse or a Google Doc as I may make a couple of these graded assignments (but you won't know until I return, so work through all of them, or at least as many as you can).Â
Loop Help:
for(int i = 0; i < 10; i++) - basic for loop
while(condition is true) - basic while loop
for(int i = 0; i < str.length; i++) - basic loop through all characters of String str
String functions that could come in handy:
str.length() - length of the String
str.charAt(#) - finds a character @ specified index
str.compareTo(other) - compares 2 Strings (lexographically - which is basically alphabetically) and returns a -, +, or 0 value
str.compareToIgnoreCase(other) - compares 2 strings (but ignores differences in capitalization)
str.contains(txt) - returns true/false based on if String str contains String txt.
str.equals(other) - compares 2 Strings and returns true if they're the same (otherwise false) - Case Sensitive
str.equalsIgnoreCase(other) - compares 2 Strings and returns true if they're the same (otherwise false)
str.indexOf(txt) - returns the index of the provided String txt.
str.toLowerCase() - returns a lowercase version of the String (does not change original)
str.toUpperCase - returns an uppercase version of the String (does not change the original)
str.trim() - returns the same String, but with any leading or trailing spaces removed.
Tools in our toolbox - and how to use them
Outputs - System.out.println (sysout)
Variables - Stored data
Primitive (store by value)
boolean - true/false
char - Individual Character
int - Whole # (+/- 2.14 billion)
double - floating point (real) #'s
Object (store by reference)
String - 2+ characters
Scanner - Get input
Using Functions
Strings
equals/equalsIgnoreCase - find out if 2 Strings are the same
charAt - get the character @ a specific location
substring - get a chunk of text
Math
PI - 14-digit-past-decimal value of pi
abs - absolute value
round - rounds a # (based on .5)
floor - rounds down (same as casting to int)
ceil - round up
pow - calculate exponents (2^4)
Operators
Basic math operators +, -, *, /, % (modulus)
Mod (%) - Gets remainder after division.
%2 - Even (0) or odd (1)
%10 - Get the last digit
%x==0 - Tells us if something is evenly divisible by x
Assignment operators =, +=, -=, *=, /=, %=
Inc/Dec operators ++, --
Boolean Operators
Logical Operators >, >=, <, <=, ==, !=
Combinors
AND && - Returns true if 2 things result in true.
 OR || - Returns true if @ least 1 thing evaluates to true.
Not ! - Returns the opposite of the result (true-->false)
Control Structures
If statements
For Loops
 While Loops
Functions
If Statements
 if - single branch
if, if, if - multiple possible branches
if, else - 1 possible branch in 2 directions
if, else if... - 0 or 1 possible branch
if, else if, else - 1 possible branch
For loops - Known # of loops/iterations
I need to loop 10 times
I need to check every letter in a String
While loop - unknown # of loops/iterations
I need to loop until... (user says stop)
Fencepost algorithms
get info
loop until a condition is met
do something
get info again
Functions - Repeatable chunks of code
Benefits - Code Reuse, Code Readability, code organization
Function calls - nameOfFunction(possibleParameters);
Parameters - what a function needs to work.
public static returnType nameOfFunction(list of parameters)
return types: void (no return) or the type of what is getting returned
Create the indexOf function to find the 1st occurance of the target (char) in a text (String).
takes in the text and the target as parameters
creates a loop that goes through every index of the text looking for the target
if it finds the target, it should return the index #
else it should return -1 (not found).
text.charAt(i) gets a character at a specific index.
Discussion Question: Given the rules we defined for choosing loops:
Is this a For Loop problem?
Is this a While Loop problem?
For Loop Solution:
public static int indexOf(String text, char target)
{
for(int i = 0; i < text.length(); i++)
{
char cur = text.charAt(i);
System.out.println(cur);
if(cur == target)
return i; //premature exit
}
return -1;
}
While Loop Solution:
<coming soon>
The Pickup Sticks game:
You are playing against the computer
There are 21 sticks in a pile (or laid out in a row).
On your turn, you pick 1, 2, or 3 sticks to remove from the pile.
The computer takes 1, 2, or 3 sticks to remove from the pile.
Play repeats until there are no sticks left.
Whoever takes the last 1, 2, or 3 sticks is the winner.
You're tasked with programming the game. Make sure you fully comprehend the gameplay (as well as the winning strategy). Play with a neighbor if you need to. Use a whiteboard or scratch paper if you need help with your step-by-step process. Always think "What is the next step in the game?".
The computer should ALWAYS try to win (unless you do the E.C. option for easy vs hard play)
Requirements/Process
The computer will ask you how many sticks to start with (It doesn't actually have to be 21). - This should be saved as a variable.
Ask the user who goes first (the player or the computer)
Repeat until there is a winner ("as long as there are still sticks...")
If it's the player's turn
Ask for 1, 2, or 3 sticks (subtracting them from the total sticks)
If it's the computer's turn
If the computer can be put into a winning position, it should take that many sticks.
Otherwise, it should randomly pick 1, 2, or 3 sticks.
Switch turns
Declare the winner (based on who took the last sticks)
Additional Requirements
Data Validation
The user & computer shouldn't be able to take:
less than 1.
more than 3 (or whatever the max grab is - see E.C.)
more than the total # of sticks (if there's only 1 stick left, you can't take 3).
Suggestions
have a function for getting the player's choice (and validating it)
have a function for getting the computer's choice (and playing smart)
EC: (1pt each)
Allow the user to decide the max# of sticks to grab (doesn't have to be 3)
Allow the user to choose an easy or hard mode
Hard: Computer plays smart (This is the default mode)
Easy: Computer always picks a random # between 1 & 3 and only plays smart if there's less than 4 sticks left (meaning the computer can win this turn)
Allow the user to choose to play another player or the computer
You must email me to let me know if you've completed the E.C. and which ones specifically - I'll miss it otherwise.
Count every vowel in a String
FeeBee
Final Part 2 - Financial Difference
Final Part 3 - [Multiple Choice Quiz - coming soon]
The final 6 weeks of the semester are geared at testing everything you've learned this semester. We'll use CodeWars, solving problems from Mr. Birkel's CodeWars Labs document.
Codewars Labs divides problems by categories, allowing me to challenge you on specific topics (variables, math, conditions, loops, etc.). Each lab covers material taught from earlier lessons in class.
Each highlighted problem solved will give you points.
Additional non-highlighted problems solved will be worth extra credit (but will not be worth as much as highlighted problems).
Be on top of your grade!
Don't ask for extra credit to make up missing work... Do the missing work.
Your grade is completely based off of work completed... Do the missing work!
Get help from Mr. Birkel long before the last week of the semester.
Available: 30 minutes before school, 30 minutes after school (most days), SET.
If you don't expect to get a C or better, you should not be moving onto the next class. Connect with me with concerns about this.
This document contains topics that were not taught in this class because they are not necessary for basic programming knowledge. These topics include Do loops, Switch Statements, and various operators. Learning them can be helpful, but I'll never quiz you on them.
The following includes old binary resources that I don't consider necessary for this class anymore as Binary isn't part of the AP CS curriculum.
Slides - Communication & Binary (Guided Notes)
Worksheet - Binary Name
Additional Resources: Binary Magic & Binary Piano
Slides - Binary to Decimal (Guided Notes)
Worksheet - Binary to Decimal
Slides - Decimal to Binary (Guided Notes)
Worksheet - Decimal to Binary
Mr Horns Intro CS Resources and AP CS A Resources
-Time 2 Code - Doesn't teach AP CS A, but does provide a great set of resources for programming, including pedagogical resources.
Parsons Puzzles allow teachers to provide code in a scambled format so that students can focus on organizing code rather than actually coding. It "reduces the cognitive load and time spent for students." See https://parsons.problemsolving.io/
Below is an example of a Parson Puzzle for generating a random #. The lines are scrambled, you're tasked with draging the lines to the right side and placing them in the correct order. Indentation matters and can be adjusted by dragging further to the side.