Showing posts with label practice. Show all posts
Showing posts with label practice. Show all posts

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

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/