VB3/Java
Mt Lebanon HS 2004-5
David Kosbie
Week #2: Programming Team problems (part 1) date: 9-Feb-05 For the next few weeks, we'll cover all the problems on the Programming Team's web site. #1. Do all the problems from 19-Jan-05 and 21-Jan-05. The 21-Jan problems are more challenging, so be sure to get to those early in the week! Hints: We discussed some hints in class today. Here are a couple others: Be sure to get an early start on these problems -- some are quite challenging, especially towards the end of the assignment, and you'll want to be able to ask questions (via email)...
You may need String.charAt(), which takes a
String and returns the kth character of the String, as in: |
Week #1: Java Basics date: 2-Feb-05 #1. Review the code we did
in class: JavaBasics.java. Modify it
in interesting ways. If you want to round to the nearest 10th, first multiply by 10, then round, then divide by 10 (think about it). You may also need Math.abs(), which takes
an integer or a double and returns the absolute value of the same, as
in: Then there's Math.pow(), which takes two
doubles a and b, and returns a to the b, as in: Also, there's Math.sqrt(), which takes one
double and returns the square root of that number, as in: As you may have guessed, there are many more Math methods, as well as a huge number of other methods. Where to learn about ALL of them? In the online API, of course! Check out: http://java.sun.com/j2se/1.4.2/docs/api/index.html. On the bottom left, you first scroll to the class you are interested in. For example, scroll to "Math" in that list and select it. After that, the main section on the right will explain every method in that class. |