Showing posts with label enhanced for loop. Show all posts
Showing posts with label enhanced for loop. Show all posts
Wednesday, October 12, 2011 0 comments

CHALLENGE:Java Tut 35-Var Length Arguments

The following is a challenge for new developers that have completed:
 Java Tutorial - 35 Variable Length Arguments by theNewBoston
 To get the most out of these challenges try them a few hours or the day after watching/following along with the actual video.
 


B.A.M.F Challenge:
B.A.M.F Challenges & why you want to always at leas try them explained Here:http://bit.ly/ogivqe
Difficulty: 1/3
Create a console program with a method that finds the average of a unknown amount of numbers(aka accepts a variable length argument in its parameters)Then test it in you're main method.

CHALLENGE!!
(Before starting any of the challenges always declare a class and a main method unless told otherwise)
 Difficulty:
 
1.Create a method that will return a int and name it "average".It should accept a variable length argument, name the variable length argument "numbers"

Inside the "average" method:

2.Declare a int variable, name it total and set it to 0.

3.Create a enhanced for loop that loops through the "numbers" parameter being passed in.

Inside the enhanced for loop:
4.set total+=x;

5.return total divided by the amount of numbers you passed in(hint: numbers.length)

Back in the main method:


6.Create a print line statement that calls the "average" method and place 8 values in its parameters.


COMPILE & PRAY TO DUKE!!!


View the video tutorial: http://bit.ly/qkxfja 

Monday, October 10, 2011 1 comments

CHALLENGE:Java Tut 31-Enhanced For Loop

The following is a challenge for new developers that have completed:
 Java Tutorial - 31 Enhanced for loop by theNewBostonTo get the most out of these challenges try them a few hours or the day after watching/following along with the actual video.
 


B.A.M.F Challenge:
B.A.M.F Challenges & why you want to always at leas try them explained Here:http://bit.ly/ogivqe
Difficulty: 1/3
 Create a enhanced for loop that sums the contents of a array.


CHALLENGE!!
(Before starting any of the challenges always declare a class and a main method unless told otherwise)
 Difficulty:
1.Create a int array with 8 values.
2.Create a int var , name it total and set it to 0
3.Create a enhanced for loop , set it to you're array. Each time it loops it should:
            *Add a value from the array to the total var
4.Print the total var to the console

COMPILE & PRAY TO DUKE!!!


View the video tutorial: http://bit.ly/n8Z8eM 

 
;