That should be "I need arrays".
Today we're tackling arrays. If you missed class then the homework will help you catch up.
Read Ch. 10, pp 237-241. Then do Questions 1, 2, 3, 4 and 14a, 14b, 14c, and, 14d.
Note that question 4 asks you to write a for-each statement but it turns out that J# hasn't implemented the for-each statement. (D'oh!)Use a regular for statement instead.
You should note that I've put a sample program that I wrote in class showing an array of strings being used in a for loop in the ICS3M\Arrays Handout folder. In addition, you can also find the powerpoint presentation for Arrays in that same folder. Make sure you look at the presentation in Notes view mode so you can see my notes which augment the information in the slides. I don't recommend that you try and rely on the slides alone without reading the text. There's a lot more information in the text that can be found in the slides.
Monday, November 17, 2008
Wednesday, November 12, 2008
J# software download site
Some people have asked me to re-link to the download site for the J# software. Here it is:
http://www.microsoft.com/express/2005/download/default.aspx
http://www.microsoft.com/express/2005/download/default.aspx
Monday, November 10, 2008
Assignment 2
Reminder: This is due on Thursday. For Homework today, I want you to write the pseudocode for evaluateBet(). In your pseudocode write:
- the actual method declaration,
- the inputs and what their possible values are
- and the output(s)
- the algorithm for executing/implementing evaluateBet()'s problem solution.
Thursday, November 6, 2008
We did some basics review over the past couple of days in an attempt to solidify students' skills. Here's what we did:
Consider:
and
Identify:
1. the loop control variable
2. the initialization code
3. exit condition
4. increment statement
5. executable satement(s)
6. what output will be produced?
We filled out the || and && and ! truth tables
Given:
-there is at least 1 other way to re-write this while condtion. What is it?
and there's also....
Given:
Loop control variable (i.e. counter): index
Executable stmt: finalValue: -= index;
increment statement: index++;
initialization statement: index = 1;
Write the for loop that implements these conditions.
Assume that finalValue has itself been intialized to a value of 7, what output would be produced by the following line of code assuming it came directly after the for loop exited.
System.out.println(“The final value is “ + finalValue);
Also
Answer the following questions:
1. What discount will be applied if I buy 175 items at a price of $8.00?
2. What discount will be applied if I buy 225 items at a price of $10.29?
3. What discount will be applied if I buy 50 items at $0.99?
4. What discount will be applied if I buy 1500 items at $11.99?
5. What discount will be applied if I buy 1500 items at $6.99?
I'll post the answers in the comments.
Consider:
for(int i=0;i<=20;i++)
System.out.println(i);
and
for(int i=45;i>=-5; i-=5)
System.out.println(i);
Identify:
1. the loop control variable
2. the initialization code
3. exit condition
4. increment statement
5. executable satement(s)
6. what output will be produced?
We filled out the || and && and ! truth tables
Given:
do
PUT Prompt for usrNum
GET usrNum
//while usrNum is out of range
while(usrNum>10 || usrNum <1)>
-there is at least 1 other way to re-write this while condtion. What is it?
and there's also....
Given:
Loop control variable (i.e. counter): index
Executable stmt: finalValue: -= index;
increment statement: index++;
initialization statement: index = 1;
Write the for loop that implements these conditions.
Assume that finalValue has itself been intialized to a value of 7, what output would be produced by the following line of code assuming it came directly after the for loop exited.
System.out.println(“The final value is “ + finalValue);
Also
if (quantityPurchased >= 150 && price > 9.99)
discount = .05;
else if (quantityPurchased >= 1000 && price > 7.99)
discount = .1;
else if (quantityPurchased >= 10000 || price < discount =" .33;" discount =" 1;">
Answer the following questions:
1. What discount will be applied if I buy 175 items at a price of $8.00?
2. What discount will be applied if I buy 225 items at a price of $10.29?
3. What discount will be applied if I buy 50 items at $0.99?
4. What discount will be applied if I buy 1500 items at $11.99?
5. What discount will be applied if I buy 1500 items at $6.99?
I'll post the answers in the comments.
Wednesday, November 5, 2008
Quantity is Quality (sometimes)
Yesterday's and today's class have been mostly devoted towards reviewing some fundamentals since I'd sensed a weakness in quite a few students. I'm going to continue with that tomorrow and, aside from some notes on documenting methods, am not planning on introducing any more new material this week. I think the fundamental weakness is that the class hasn't written enough code for the basic constructs to be at your fingertips. Once you've written a hundred for loops you won't be struggling with how to put one together anymore.
Quantity is (can lead to?) quality. It's like martial arts. You practice the same move over and over and over again. You do the same thing a thousand, two thousand times. The point? To insert the moves into your nervous system. To make this artificial sequence of moves something that you do automatically, instinctively. Once you reach that level of integration then you can start improvising with the moves and do creative things with them.
Computer Science, then, as a form of mental karate.
The other big challenge that a lot of students are facing right now has to do with the difficulty of translating the requirements laid out in the review exercises into a solution implemented in the code. It's like word problems in math. You have to keep practicing the process of turning the descriptions into java code. How do you this if you don't already know how to do it? That's the sixty-four thousand dollar question.
One part of the answer is to write some *&(@#$ stuff down. The program description contain pieces of the puzzle you have to put together. Get them out of your head (where they reside after you read the problem) and onto some paper so you can look at them.
Another part of the answer is to do lots of them. Again, practice is going to lead you in the right direction. Every problem that you successfully solve is an approach that enters your repertoire and that you then have available for re-use down the road.
Quantity is (can lead to?) quality. It's like martial arts. You practice the same move over and over and over again. You do the same thing a thousand, two thousand times. The point? To insert the moves into your nervous system. To make this artificial sequence of moves something that you do automatically, instinctively. Once you reach that level of integration then you can start improvising with the moves and do creative things with them.
Computer Science, then, as a form of mental karate.
The other big challenge that a lot of students are facing right now has to do with the difficulty of translating the requirements laid out in the review exercises into a solution implemented in the code. It's like word problems in math. You have to keep practicing the process of turning the descriptions into java code. How do you this if you don't already know how to do it? That's the sixty-four thousand dollar question.
One part of the answer is to write some *&(@#$ stuff down. The program description contain pieces of the puzzle you have to put together. Get them out of your head (where they reside after you read the problem) and onto some paper so you can look at them.
Another part of the answer is to do lots of them. Again, practice is going to lead you in the right direction. Every problem that you successfully solve is an approach that enters your repertoire and that you then have available for re-use down the road.
Subscribe to:
Posts (Atom)