HTW Berlin Medieninformatik HTW Berlin
Fachbereich 4
Internationaler Studiengang
Internationale Medieninformatik (Bachelor)
Info 1: Informatik I
Summer Term 2014

Laboratory 5 : Lotto and Technical Support

Pre-lab

This week's lab work is intended give you practice using the Random class and HashMaps.

What to Bring to Lab

Please bring these exercises printed out or written out with you to lab. Please have your name on your page.

P1. How do you generate random numbers between 1 and 10 with Java? In what package is the library?

P2. How do you define an array that can count how often the numbers between 1 and 10 are generated? We call this a frequency table.

P3. Where can you find information about the lotto numbers that have been picked in Germany on the Internet?

P4. Where can you find information about javadoc on the Internet?

Post-Lab, AKA  What To Turn In

Your completed assignment, submitted in Moodle as a pdf, should include:

Lab assignments are due the night before your next class at 22.00. They may, of course, be turned in earlier. You hand them in by preparing the report in PDF and submitting it to Moodle.


Assignment

Lotto

  1. Create a class that will be doing some testing of random numbers. Make a method that picks the six numbers for next Saturday between 1 and 49 and returns them as one data type. What type will you be using to model the lottery pick? Explain! Note that no two numbers may be the same! How do you avoid this?
  2. Now write a method that takes a lottery pick and counts how often each number is picked.
  3. Now pick the 6 lotto numbers 1000 times. Print out the frequencies.
  4. Repeat for 10,000 times. And 100,000 times. And 1,000,000 times. Put your results in a nice table. Any observations on the results?

Technical Support

  1. Download the basic TechSupport project. Expand it to give random responses as we did in class.
  2. Now use the method split from String and a HashMap to give appropriate answers. Make up lots of cool responses.
  3. How can you deal with punctuation marks? What if there is more than one space between words? Can your tech support system deal with this?
  4. Document your code with javadoc!
  5. (For the bored) There are often synonyms that should provoke the same response. Can you figure out how to store only one response even if there are a number of different words that trigger this response?
  6. (For the really bored) Make your answers multilingual. At first you can just set the language at any point, but then you want to read the locale form the local machine to determine how to answer.
  7. (For those who are really, really bored) Choose your answer language at random, and include Hebrew and Arabic script as possible languages for answers. Note: These languages are written right to left.

Writeup

Submit your writeup as your post-lab to the Moodle area.

 


Some rights reserved. CC-BY-NC-SA Prof. Dr. Debora Weber-Wulff - CC-BY-NC-SA
Questions or comments: <weberwu@htw-berlin.de>


The exercises are adapted from Objects First with Java, A Practical Introduction Using BlueJ. David Barnes & Michael Kölling, 2011