Programming 1, fall 2007 -- Demonstration 10

Most things of Programming 1 have been seen now. Exception handling and a thousand "how to do this or that using the API" are still unseen. All we need to do then is to learn how to apply all this to make application programs, based on a "job description" - "I want a program for doing this and that and all other things".

Still postponed from previous sessions:

For the first three, we'll look at example answers to the questions in demonstration 8. For Exceptions, we look at reading integer and floating point input from the console. Later we'll look at file input/output in Java.

Outline of today

You will find the structure of the exam of this course as a PDF file there:

http://www.cc.jyu.fi/~nieminen/ohj1/english/examples/ohj1_exam.pdf

Today we look at the correct answers, and how they are found.

Exercise 1: A small project work

We'll have to cut a few corners. The international people will do the following project work. It is very important that you do this as soon as possible. I'll check your works, and give you feedback, when you send them to me via email.

Work assignment:

Tool for the meteorologist

The program shall read the following values from the console (standard input): Minimum and maximum temperature, and the amount of rain for each day of a week.

Then, after inputting the values, the program shall output the following:

  • Mean value (average) of all the measurements, yielding the average minimuma and maximum temperature, and the average amount of rain for one day.
  • The hottest day of the week ("monday", "tuesday", ... ) based on the maximum temperatures measured.

Restrictions:

  • Input, each calculation, and output shall be in separate methods.
  • Exactly one Java compilation unit
  • No compiler errors or warnings
  • Works as described above
  • All things defined static
  • No global variables
  • Will not "crash" because of unhandled exceptions.
  • Contains complete javadoc comments, including @author @version @param and @return tags.