Chapter  1 Exercises

 

กก

  1. Get Hello World to work.
  2. Personalize the Hello World program with your name so that it tells you Hello rather than the somewhat generic "World."
  3. Write a program that produces the following output:
    Hello World!
    It's been nice knowing you.
    Goodbye world!
    
    
  4. Write a program that prints all the integers between 0 and 36.
  5. Imagine you need to open a standard combination dial lock but don't know the combination and don't have a pair of bolt cutters. Write a program that prints all possible combinations so you can print them on a piece of paper and check off each one as you try it. Assume the numbers on the dial range from zero to thirty-six and three numbers in sequence are needed to open the lock.
  6. Suppose the lock isn't a very good one and any number that's no more than two away from the correct number in each digit will also work. In other words if the combination is 17-6-32, then 18-5-31, 19-4-32, 15-8-33 and many other combinations will also open the lock. Write a program that prints out a minimal list of combinations you would need to try to guarantee opening the lock.
  7. Write a program that randomly fills a 10 component array, then prints the largest and smallest values in the array.
  8. Hand in the first page of a print out of the documentation for the java.text.DecimalFormat class.
  9. Hand in a screen shot of your web browser's Bookmarks or Shortcuts menu showing a bookmark for the Java class library documentation.
  10. Install jEdit. Hand in a screen shot of the program showing the hello worls source code.
  11. Sign up for an account on utopia.
  12. Go to http://utopia.poly.edu/ and follow the instructions for signing up for a home page.


List | Previous | Next