| RHS => Allan => Basic Programming => Exercises => ReminderList |
Updated:
02/02/2004 23:36 WebMaster: allanhn@rhs.dk |
Reminder List
The problem
You are to construct a program, which can print the same reminder to a certain
number of persons.
This implies that a certain program block (reading
a name and printing the standard text) is to be repeated, until the reminder
for the last person has been printed.
You must use a for-loop!
Hint
Below follows a typical example of how to read and print a number of recievers
using a loop, note that the sender is the same for all reminders:
various definitions and declarations
including declaration of a constant (number)
read sender
for (int i = 0; i < number; i++) {
read name of reciever
print text (including sender)
}
Note that "i" is a count variable of the type int.
Assignment 1
Start by opening Reminder3.java into the editor.
Save into a new file ReminderList.java and then
change the name of the class to this name.
Now, change the method printReminder(), and be aware
of how the for-loop encapsulates the block !!
Compile and save.
Change ReminderApp to use your new class.
Compile and run.
Assignment 2
As can be seen, the reminders come out too close to each other.
Therefore insert a for-loop which prints 5 blank lines after
each reminder.
Save, compile and run!