Friday, March 11, 2016

AP CompSci 2015-2016 Feb+Mar: Iteration Statements Done!

AP CompSci 2015-2016 Feb+Mar

Iteration Statements Done!
We finally finished looking at For and While loops. Unfortunately, we didn't get very far with Midterm Week and Snow Days getting in the way! So, we spent February and part of March on this topic too.

One of the first lab projects we did involved a loop calling nextPower() from a PowerGenerator class we wrote. The main() method had a loop generating a table of powers from base^0 to base^11 given any integer base from args[0]. We ran it for powers of 2, 3, 5, etc. As soon as we hit base 10, we went over maxint. So, we changed the return type of nextPower() to long. 

We finally had to figure out that a signed int has a maximum value equal to 2^(number of bits)-1. So, the int type has a maxint of 
2^31-1= 2147483647 but long integers have a maxint of 2^63 - 1 = 9223372036854775807! 

We even talked about the difference between 1bit, 2bit, 4bit, 8bit, 16bit, 32bit, 64bit, 128bit and 256 bit microprocessors. Gotta get me one of those 1bit PCs!


YOUTUBE WEDNESDAYS: 
What's the CooKoo's Egg Virus?
What does PI sound like?

AP Computer Science + JAVA
SCREENCASTS





Well, that's all folks!

No comments:

Post a Comment