Dear Students,
I’m back as of 3/05/12 ! GO to Homework Page
———————————
Lesson for Wednesday – Monday , 2/29/12 – 3/5/12
Yesterday, we went to www.hp.com and looked at how we can select and customize
a laptop or notebook computer. In the next few days, I would like you to
research your options, customize, and select a computer and accessories that
you want. Go all the way to adding the item to your cart, and getting your
final price. Hopefully, you will find a great coupon and code on the internet
that you enter to reduce your final price. ( You don’t need to buy it.)
The next step is to use MS Word to write about
what you selected and why you selected the options you ended up with. For
instance, why did you choose the battery option, why did you end up with the
amount of gigs in the RAM you selected, etc. Try to be realistic – - – don’t
just add all the most expensive options and end up spending $2000 for your
laptop. Be sure to include all your options, discounts, and final cost and hand
your paper in when finished.
—————————————
Lesson for Monday, 2/27/12
Hopefully, I will see you today and we talk about SmilingFace and your next assignment.
—————————————
Lesson for Monday – Wednesday, 2/13 – 2/15/12
It’s finally time to use TurtleGraphics again. In the same way we built the Student class, we will write a program that will define a SmilingFace.
-
Please read pages 159-162. From the bottom of page 162-163, write the class SmilingFace. Remember, your program, if working correctly, will not give us any actual results. The second program we write will ‘call’ to the original program, and then use it to give us results. This program is called TestSmilingFace and is on page 164. If your smile is not working correctly, find the error and repair it. ( The error may be in either program.) Please save these programs.
—————————————
Lesson for Tuesday – Friday, 2/7 – 2/10/12
Now is the time to take what we learned about OOP and classes. What we are going to do is build a new class (program) that will give a description and explanation of how objects are used in that class. The first program we write, if working correctly, will not give us any actual results. The second program we write will refer to the first program, and then use it to give us results. It is easier to do it than explain it.
So, let’s go to our Java textbook, pages 140-141, and write the Student.java program. As you write this program, understand that the purpose is to set up a base program that explains how to initialize a student’s name and test scores, and format it for use in other programs to be written. We can’t get any results for this first program, because it does not actually ask for names and test scores.
After writing the Student program, we will need to write a second program to see if both of them work correctly. So we now go to pages 144-145 and write the program TestStudent.java . Notice on line 3 of this program it refers to Student s1,s2; . If your program works correctly, it will go looking for the first program, Student, and use it to format your results. If it is not working correctly, you may have to go back to the Student program and look for errors.
Lastly, please read pages 146-148 about designing a 3rd program that will also use the first program to manipulate information and provide additional results. Build this program StudentInterface.java on pages 148-149 and get it working.
If you are having difficulties, ask others in the class to assist you in finding errors that need to be corrected. GOOD LUCK !
—————————————
Lesson for Monday, 2/6/12
A number of students have emailed me, asking for more time to complete their assigned work. Please take today and catch up with any work you haven’t completed or handed in.
—————————————
Lesson for Tuesday January 31, through Friday February 3, 2012
Tuesday – - -Don’t Fear the OOP !! This is the subject of our readings for the rest of this week. OOP stands for Object-Oriented Programming. This concept of OOP is to name and use an object to be able to greatly expand the way we can build programs.
definition = An Object-Oriented Program consists of a group of cooperating objects, exchanging messages, for the purpose of achieving a common objective.
Please start by reading pages 19-21 in you Java textbook, then answering the questions and handing them in.
Only newer languages like Java and C++ have this ability.
Wednesday – - - Because it may be difficult to understand the reading above, I have added more readings by a very intelligent young programmer named Sepp.
Please go to this address and read the entire page today.
http://www.lynnclassical.org/OOP%20by%20Sepp.htm
Thursday – - – Please go to this address and read the entire page today.
http://www.lynnclassical.org/oop2.htm
Friday – - - Based on what you have read, use MS Word to explain in your own words what object-oriented programming is all about. Hand in.
—————————————
Lesson for Monday January 30, 2012
I have a couple of questions for you. Are these assignments going too fast for you to keep up with ? Are you having problems getting the programs to work properly, and what kind of problems are they? If your answer is yes to either question, can you take a few moments and email me (at home) to brasss@lynnschools.org . Thanks so much !
Write and independent “for” program. Call it IndyFor.java .Get it working and save it in your folder.
—————————————
Lesson for Thursday and Friday, January 26 and 27, 2012
Read pages 116-119 about Errors in Loops. Answer questions from Exercise 4.9 on page 119, and hand in (use MS Word.) Read page 120.
On page 123, turn Project 4-3 into a program, naming it Telephone.java . You can make up your own formula or use mine to figure out how much each telephone call costs – - -
cost = 1.15 + (minutes -2) * .50
On page 127, make Project U1-3 into a working program called VideoRental.java.
—————————————
You will have a Mid-Year exam which will cover information from Chapters 1 -4 in the Java textbook that we have discussed or worked on. There will be some short answer questions, some multiple choice questions, and programs to write. You will not be using your computer but be sure to bring your textbook in for the exam.)
Java- Review Concepts for Midyear Exam
What is the difference between using an ‘if’ control structure and a ‘while’ control structure ?
What is the advantage of using a ‘for’ structure over another type ?
Be able to write a simple ‘if/else’ program.
Be able to write a simple ‘while’ program.
Be able to write a simple ‘for’ program.
—————————————
Lesson for Wednesday and Thursday January 18 and 19, 2012
Build a program that will use a “break” command inside it and name it IndyBreak.java. Build a second program that uses an “if” or “if/else” program inside a “for” program and call it IndyNesting.java .
—————————————
Lesson for Friday and Tuesday January 13 and 17, 2012
Pages 110 – top of page 112 - – - Read about nested control statements, which mean you are using one type of control structure inside another. Also. read about the “break” statement. Take all four partial programs and build them into working programs:
Divisor.java
PrimeNumber.java
PrimeWithBreak.java
Sentinel.java
—————————————
Lesson for Wednesday – Thursday January 11-12, 2012
So how many male/female rabbit pairs are there after one year (12 months)?
![]() A Rabbit |
Month #0 – At the beginning of the experiment, there is one pair of rabbits.
Month #1 – After one month, the two rabbits have mated but have not given birth. Therefore, there is still only one pair of rabbits.
Month #2 – After two months, the first pair of rabbits gives birth to another pair, making two pair in all.
Month #3 – After three months, the original pair gives birth again, and the second pair mate, but do not give birth. This makes three pair.
Month #4 – After four months, the original pair give birth, and the pair born in month #2 give birth. The pair born in month #3 mate, but do not give birth. This makes two new pair, for a total of five pair.
Month #5 – After five months, every pair that was alive two months ago gives birth. This makes three new pair, for a total of eight.

Can we find a way to predict the total number of rabbits after one year without going through each individual pair? Of course we can, we just need a formula to work with.
The way you find the total number of rabbits for each month is to find out how many pairs of rabbits were newly born that month and add that to the number of rabbits you had before the new ones were born.
![]() A Rabbit |
![]()
All we need to do is find the number of rabbit pairs that were alive before the new ones were born. It should be obvious that this is simply the number of pairs alive the month before.
In other words, to find the total number of pairs of rabbits, you simply add together the number of pairs that were alive in the preceding two months.
Now, do you know of any series of numbers which begins with one and one and continues by adding the preceding two numbers to get the next? Of course you do. It’s the Fibonacci series.
So what is your answer to this problem now?? Please hand in, showing your calculations.
————————————————————————
To double check your answer, build this program and see if it works, inputting 12 (for 12 months.)
import TerminalIO.KeyboardReader; public class Fibonacci { public static void main (String [] args) { KeyboardReader reader = new KeyboardReader(); int n; int fib; int a,b,count; while (true) { n = reader.readInt("Enter a positive integer or -1 to quit: "); if (n == -1) break; while (n <= 0) n = reader.readInt( "Enter a positive integer or -1 to quit: "); fib = 1; a = 1; b = 1; count = 3; while (count <= n){ fib = a + b; a = b; b = fib; count = count + 1; } System.out.println ("Fibonacci of " + n + " is " + fib); } } }
—————————————
Lesson for Monday – Tuesday January 9-10, 2012
Leonardo Fibonacci was born over 900 years ago. As a 9 year old, he went to work counting inventory in a candle warehouse his father ran for the city of Pisa in Italy. He got tired and bored of using the Roman Numeral System to write and count items in the warehouse – - – like MDCLVIII. So he learned a new system from Arab sailors on the ships.
He was one of the first people to learn and introduce the Hindu-Arabic number system into Europe – the positional system we use today – based on ten digits with its decimal point and a symbol for zero:
1 2 3 4 5 6 7 8 9 0
So he wrote a handwritten book (because there were no printing presses yet) over and over again.
His book on how to do arithmetic in the decimal system, called Liber abbaci (meaning Book of the Abacus or Book of Calculating) completed in 1202 persuaded many European mathematicians of his day to use this “new” system. His book describes (in Latin) the rules we all now learn at elementary school for adding numbers, subtracting, multiplying and dividing, together with many problems to illustrate the methods.
As a result, he stopped working in the warehouse and the city of Pisa supported him while he studied mathematics full time. Fibonacci is now best-known for his Fibonacci Formula. Your assignment is to read the following and try to answer the problem which he worked on to invent his formula.
The Rabbit Problem
1. You begin with one male rabbit and one female rabbit. These rabbits have just been born.In the year 1202, Fibonacci became interested in the reproduction of rabbits. He created an imaginary set of ideal conditions under which rabbits could breed, and posed the question, “How many pairs of rabbits will there be a year from now?” The ideal set of conditions was a follows:
2. A rabbit will reach sexual maturity after one month.
3. The gestation period of a rabbit is one month.
4. Once it has reached sexual maturity, a female rabbit will give birth every month.
5. A female rabbit will always give birth to one male rabbit and one female rabbit.
6. Rabbits never die.
*So how many male/female rabbit pairs are there after one year (12 months)?
Use pencil and paper to solve this problem. Do not use your computer. Circle your guess with the paper you used to do your figuring.
—————————————
Lesson for Thursday – Friday January 5-6, 2012
MagicAge.java
Write an if/else program where to get into an over-21 nightclub, you need to put your Identification Card or Drivers License into a ‘reader machine’ at the entrance door. If the birth date is equal to or more than 1051991, “Welcome to the Club”, else “Come back when you are older”.
Save your work.
—————————————
Lesson for Wednesday – Friday December 21st – 23rd, 2011 -
The “for” Control Statement is considered the most powerful. Why? Because you squeeze important factors into a one-line statement. Read the bottom of page 105- 109 and turn the following partial programs into full working programs.
Top of page 106 SumFor.java
Middle of page 106 – IncrementFor.java
Bottom of page 106 – SquareFor.java
Top of page 107 – SpiralFor.java
Bottom of page 107 – RandomFor..java
—————————————
Lesson for Tuesday December 20th, 2011 -
Complete Exercises #1-5 on 4.6 on Page 105 except for #4b. Turn this into a working program called Product.java. Hand in the written work.
—————————————
Lesson for Monday December 19th, 2011 -
Once you are caught up with previous work, please continue with the Control Structure ‘while’. Write an independent program called IndyWhile.java, make sure it works correctly,, and save it for me to see.
—————————————
Lesson for Thursday and Friday December 15/16th, 2011 -
I hope you’re working on, and enjoying, Ms. Frost’s Auto Buying Lessons.
—————————————————–
Java Programming - December 13 and 14, 2011
Now that you are able to use the “if “and “if/else” Control Statements, let’s look at another one called “while”.
Read about the format of this kind of statement on pages 101 to 104. Turn the partial programs into working programs with correct results on:
page 102- call it Compute1.java
page 103- call it Flexibility.java
page 103- call it Backwards.java
page 104- call it TaksControl.java
—————————————————–
Java Programming – December 8-13, 2011 Write and save the following 5 programs labelled a) through e) .
a) The following is a simple if/else program. Build and execute this program. (Read it first to see what the results might be.)Change what to need to make this program work.
public class IfElseIfElseExample {
public static void main(String[] args) {
int i = 10;
if(i > 100)
System.out.println(“i is greater than 100″);
else if(i > 50)
System.out.println(“i is greater than 50″);
else System.out.println(“i is less than 50″);
}
}
b) Now rewrite the program as IfElseIfElse2.java and make it into an interactive program (TerminalIO.) Remember to take the value off the variable i when you rewrite it.
—————————————–
c) The following is an if/else program with a value for the test score. Build the program, call it TestGrade1.java.
(The following program, TestGrade.java, assigns a grade based on the value of a test score: an A for a score of 90% or above, a B for a score of 80% or above, and so on.
public class TestGrade1 {
public static void main(String[] args) {
int testscore = 76;
char grade;
if (testscore >= 90) { grade = ‘A’; }
else if (testscore >= 80) { grade = ‘B’; }
else if (testscore >= 70) { grade = ‘C’; }
else if (testscore >= 60) { grade = ‘D’; }
else { grade = ‘F’; }
System.out.println(“Grade = ” + grade);
}
}
The output from the program should be:
Grade = C
You may have noticed that the value of testscore can satisfy more than one expression in the compound statement: 76 >= 70 and 76 >= 60. However, once a condition is satisfied, the appropriate statements are executed (grade = 'C';) and the remaining conditions are not evaluated.
d) Now, rewrite the above program as a TerminalIO program so the results now ask for the test score. Name the new program TestGrade2.java . Make sure you check all possible grades results to make sure the program works.
e) Build an if/else program called IfElse2.java that will work similarly to the TestGrade program. You can make it simple by having only one “if” and one “else” in this program.
—————————————————–
Your substitute teacher will be giving you the following Handout:
Java Programming – December 6-7 , 2011
Learning the “Control Structures” - – - if and if/else
—————————————————–
Welcome to JAVA !

![[Rabbit - Matt Anderson]](http://library.thinkquest.org/27890/media/photoRabbit.jpg)
![[Rabbit - Matt Anderson]](http://library.thinkquest.org/27890/media/photoRabbit2.jpg)
