- Click to download the java file for Homework 3.3 - Diamond with Parameters
Information for homework, projects, and tests for the 2014-2015 school year
Showing posts with label homework. Show all posts
Showing posts with label homework. Show all posts
Saturday, October 4, 2014
Homework 3.3 - Diamond with Parameters
Homework 3.2 - computePower
Click link for Homework 3.2 - computePower
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
-
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.
-
Create a method called “computeSquare” that has 1 integer parameter. The parameter variable name should be “square”
-
In computeSquare method, multiple “square” by itself and then println the result.
-
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.
-
Run your program, the results should be:
1
4
9
16
-
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.
-
Run your program, the results should be:
1
4
9
16
-
Email your file to hw-cs-castlemont@googlegroups.com
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.
Create a method called “computeSquare” that has 1 integer parameter. The parameter variable name should be “square”
In computeSquare method, multiple “square” by itself and then println the result.
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.
Run your program, the results should be:
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.
Run your program, the results should be:
Email your file to hw-cs-castlemont@googlegroups.com
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.
Thursday, September 4, 2014
Homework 1.6 Feedback
Great job on this homework assignment! Here are some trends across the class that I wanted to point out:
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?
- 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:
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?
Subscribe to:
Posts (Atom)