Medialogy Semester 4, Aalborg University
Object-Oriented Analysis, Design and Programming

Session 3 Exercises: Introduction to Java
=========================================

David Meredith 18 February 2009

Introduction
============

These exercises are designed to exercise and 
test your basic Java programming skills.

Create a new package in Eclipse called:

dk.aau.imi.med4.ooadp2009.javaintro.test

Store all the new Java classes you make when
answering the following questions in this
package.
When solving the following problems, you may
find it useful to look at the following files
that are available on Moodle:

    * JavaIntro01HelloWorld.java
    * JavaIntro02ints.java
    * JavaIntro03boolean.java
    * JavaIntro04double.java
    * JavaIntro05Loops.java
    * JavaIntro06Conditionals.java
    * JavaIntro07Arrays.java
    * JavaIntro08UserInput.java
    
Problems
========
    
Q1. Write a program that asks the user for his or
her name and then prints out a greeting that includes
the user's name.

Q2. Write a program that asks the user for two doubles
and prints out the sum of the two numbers.

Q3. Write a program that asks the user for two ints
and prints out the smallest of the two numbers.

Q4. Write a program that asks the user for two ints
and prints out the largest of the two numbers.

Q5. Write a program that asks the user for two Strings
and prints out the one that comes earlier in the
dictionary. (Hint: Use the String compareTo method to 
find out which of two Strings comes first 
alphabetically. For example, if
a.compareTo(b) == -1
then a comes before b.)

Q6. Write a program that asks the user for 10 integers 
and then prints out the numbers in the reverse order
from that in which they were entered by the user.

Q7. Write a program that asks the user for 10 doubles
and then prints out the smallest number.

Q8. Write a program that asks the user for 10 doubles
and prints out the largest number.

Q9. Write a program that asks the user for 10 doubles
and prints out the mean.

Q10. Write a program that asks the user for 10 Strings
and prints out the one that comes latest in the 
dictionary.

Q11. Write a program that asks the user to enter 10
doubles and then prints out the doubles in 
ascending order.
Hints: if you want two or more things to be true
in order to satisfy a conditional, use the && operator
for "and". For example:
if (x > 10 &&  x < 20)
	System.out.println(x);
will only print out x if it is greater than 10 and
less than 20.

Q12. Write a program that asks the user to enter 10
Strings and then prints out the Strings in 
alphabetical order.