Tuesday, September 30, 2014

parameter example: dog years

public class parameterExample  {

    public static void main (String[] args) {
        int ruff = 10;

        dogYears (20);
        dogYears (7);
        dogYears (12);

         //  this wasn't talked in class but could be useful for extra credit

        dogYears (ruff);

    }

    public static void dogYears (int human_years) {
        int dog_years;

        dog_years = human_years * 7;

        System.out.println (dog_years);

    }
}

Monday, September 29, 2014

Homework 3.1

Homework - Lesson 3.1   Parameters

Due 9/30/2014


  1. In eclipse, create a new class called “FirstnameLastnameHwk3_1”, where “FirstnameLastname” is your first name and last name.  Include a main method when you create your class.
  2. Create a method called “computeSquare” that has 1 integer parameter.  The parameter variable name should be “square”
  3. In computeSquare method, multiple “square” by itself and then println the result.
  4. In your main method, call computeSquare 4 different times.  The first time, pass in the number 1.  The second time, pass in the number 2.  The third time, pass in the number 3.  The forth time, pass in the number 4.
  5. Run your program, the results should be:
1
4
9
16
  1. Extra Credit, in your main method, remove the previous calls to computeSquare and write a for-loop that will call computeSquare 4 times (make 4 a constant variable in main and name it “NUMBER_OF_SQUARES”).  Have the iterator start at 1 and pass the iterator as the parameter to computeSquare.
  2. Run your program, the results should be:
1
4
9
16
  1. Email your file to hw-cs-castlemont@googlegroups.com

Sunday, September 28, 2014

UPDATE: We Won Runner-Up at the Hackathon

...in the category of "Most Likely to Go to Market!"


Silicon Chef Hackathon

Hey all -- hope studying for tomorrow's quiz is going well.

If you get the chance, make sure to ask Ronye, Laura, Sandra, or myself about this weekend's hardware hack.  We built a student response system that allows us to input student feedback and pair those who rate themselves as high (gets it!) with those who identify as needing help.  We learned a lot about Arduinos and about coding in C to get this done (we used lots of for loops!). 

Our final product: Check Yo Self!

#CastlemontCodes Dream Team.

If you want to try Arduinos for yourself, I now have 4 in the classroom that you can use.  Also, I will let you know about the next hack-a-thon and you should join us!


For those who are interested, here is the text of our code.

Friday, September 26, 2014

Study Help Screencasts from Your Peers!

Mad props to Lauren, Sandra, Evelyn, and Elvis who made screencast of some today's review problems.  They explain their thinking and how they arrived at their answers.   Watch them as review for your QUIZ on MONDAY. The slides are posted underneath the videos.

Elvis explains nested for loops


Elvis explains for loops


Sandra and Evelyn explain operators and assignment

Sandra and Evelyn explain nested for loops

Lauren explains for loops

Thursday, September 25, 2014

More Java Coding Challenges

I just across this coding exercise site today: http://codingbat.com/java

This looks GREAT. Check out the AP section. 

And I just remembered about this other site that might come in handy too:  http://coderbyte.com/CodingArea/Challenges/

Wednesday, September 24, 2014

Sunday, September 21, 2014

How to submit homework files

  1. Open a new email messsage
    1. To: hw-cs-castlemont@googlegroups.com
    2. Subject: Homework # 
      1. replace # with the homework number
  2. Switch to Eclipse
  3. Click Window... Show View... Navigator
  4. In the Navigator window, click your <project name>... src
  5. Find your java file then click and drag the file over to your email message
    1. This works with GMail. Let us know if this doesn't work with other email providers.


Saturday, September 20, 2014

Project Euler Programming Problems

For anyone looking for an extra challenge, check out https://projecteuler.net/. The website has a set of increasingly challenging mathematical problems that can be solved with a computer program. It will introduce you to new programming techniques and algorithms, but you should be familiar with many of the math concepts. Enjoy!

Thursday, September 18, 2014

Nested Loop Problem

Print the following grid numbers to the console. Consider breaking the problem into three portions colored yellow, red, and green below. 



Monday, September 15, 2014

Nested loops


Below is a video on nested loops.  The instructor provides a great example.



Wednesday, September 10, 2014

Ted talk on Algorithms


Here is an interesting link to a TED Talk on Algorithms and how they impact our lives.

http://www.ted.com/talks/kevin_slavin_how_algorithms_shape_our_world

Tuesday, September 9, 2014

Friday, September 5, 2014

Guest Presenter: Daphne LaRose

Hope you all loved Daphne's presentation like I did! Here is Daphne's email and some things she mentioned:

Daphne's email: daphne.larose@gmail.com
Daphne's Tumblr: blackfemalecoders.tumblr.com
GEM Fellowship: https://www.gemfellowship.org/gem-fellowship
Open Oakland Mesh Network: https://peoplesopen.net/

GEM Fellowship

Here's the link to the GEM Fellowship that Daphne recommended in her presentation: https://www.gemfellowship.org/

Looks like a great option!

CS at Harvey Mudd College

For you seniors and anyone thinking about college, take a look at Harvey Mudd College. It's the engineering school of the Claremont Colleges group of colleges. Maria Klawe, the President of Harvey Mudd, is a computer scientist and really improved the undergraduate Computer Science curriculum to cater to students new to programming. And she increased the number of women majoring in Computer Science. 

To read more about Harvey Mudd and Maria Klawe, check out this article: http://www.nytimes.com/2012/04/03/science/giving-women-the-access-code.html?pagewanted=all&_r=0

Thursday, September 4, 2014

A Comment about Curly Brackets { }

The lines of code inside a method start with a { and end with a }. By default Eclipse puts the starting curly bracket on the same line as the method name. And it puts the ending curly bracket directly underneath the "p" in public. See the example below

This is a great habit because you can easily find its matching starting curly bracket. Sometimes I will even add a comment after the ending curly bracket to indicate the method that it is ending. Plus most Java developers follow this convention, so it makes it much easier for other programmers to read your code.


Please follow this convention, even in your handwritten assignments. The AP exam is handwritten so you'll need to be able to write out legible code. Legible code makes it easier for the person reading and grading your AP exam. 

public class Program {
    public static void main(String[] args) {
        sayGoodMorning();    
    } // end of main()
    public static void sayGoodMorning() {
        System.out.println("Guten morgen!");
        System.out.println("Hello! My name is Jason!");
    } // end of sayGoodMorning()
} // end of Program

Homework 1.6 Feedback

Great job on this homework assignment! Here are some trends across the class that I wanted to point out:

  • When debugging code make sure the following things are matched correctly:
    • curly brackets {}
    • parentheses ()
    • double quotes "" 
  • Glad to see escaped sequences used properly! But using many \n in one println() statement results in super long lines of code. They can be difficult to read as a programmer because you have to scroll right and left to see the whole line of code. Use multiple println() statements to improve code readability. 
  • Question 4 asked to find four errors. Three of those errors are "compilation" errors. Meaning that when you try to run the program, you should see three errors in the Error window.
    The fourth error is a "functional" error. After you fix the first three errors, the program will run in Eclipse, but it won't print what was expected: a modified version of the first line of the Gettysburg Address by Abraham Lincoln. The block comment, /* */, cut out all men, but didn't replace it with anything. It should print:
Four score and seven years ago, 
our fathers brought forth on
this continent a new nation
conceived in liberty, 
and dedicated to the proposition
that
all 
PEOPLE 
are
created
equal. 

What do you need to change to print this?

Wednesday, September 3, 2014

methods();

  • Declaring
public static void printWarning() {
System.out.println("This product causes cancer");
System.out.println("in lab rats and humans.");
}
  • Calling
public static void main(Strings[] args) {
printWarning();
}
  • Output
 This product causes cancer
in lab rats and humans.

Tuesday, September 2, 2014

Comments

// This is a valid comment
// So is this

/ This is not a valid comment (missing a forward slash)

/* This is another way of writing a comment */

/* This is also a valid
way of writing a comment */

/* This is not a valid comment because you are missing the star here /

/* This is the eclipse
 * way of writing a comment
 * with multiple lines.
 */

Class Announcement

Hello Castlemont Coders --

Hope that you all are enjoying the long weekend.  Please read the announcements below!

ABSENCES and TARDIES:
These were a huge issue in the first week.  I know that some of you were added to the roster late.  Still, this does not excuse the amount of missed class time our class collectively totaled over the course of the week.  There were 24 tardies last week.  Every minute counts.

I won't harp on this point too much, but now is time to get serious about your commitment to computer science.  We are so fortunate -- 9 out of 10 high schools in America do not offer computer science courses.  Of the 3.6 million AP tests administered last year, only 3,000 were to black or Latino students in CS.  We need to take advantage of what we have been given.  (Also, check my stats here.)

My expectations are the following:  you need to be in the classroom, computers on and Eclipse loaded, by 8:25 so that class starts at 8:30 on the dot.  I know that you all are capable of this.  Let me know how I can support you.

COMPUTERS:
The laptops are ordered and we are just waiting for them to arrive.  Thank you for your patience.  It looks like we may be 3-4 short, so if you have a laptop that you haven't yet told me about, let me know.

SURVEY:
Please fill out the following survey for TEALS, the organization that brought us Mark, Tikku, Jason, and James.  I need everyone to do this by next Friday (but do it now, please).

INSTRUCTOR FEEDBACK:
Do you have comments, advice, or questions for our instructors?  They would love to hear from you about your experience in AP CS thus far.  Fill out this feedback page.

Looking forward to seeing you (on time!) tomorrow morning.

Hugs,
Shorall

Monday, September 1, 2014

println tip

When needing to format a single println statement, using a backwards slash to instruct the compiler to format it.

\t = tab
\n = new line
\" = quotation mark
\\ = backslash