RHS =>  Allan =>  Basic Programming => Exercises => Reminder Updated:  02/02/2004 23:36
WebMaster: allanhn@rhs.dk

REMINDER

Background
Javan Wonder is a borrower at the "Fantasy Library".
He is too late with his payment, 155.80 DKK, for special on-line services (e.g. electronic journal mailing list).
Therefore a reminder is to be printed and sent.

The problem
You are to create a program, which can print a reminder on the amount DKK 155.80 from the company Angels Incasso A/S to Javan Wonder.

The reminder should demand payment by a certain number of days (say 14).
First line:   To Javan Wonder
Last line:   Angels Incasso A/S

Assignment 1
Start by making a class Reminder1 (make a folder called Reminder for the files) with a printReminder() method, as shown below:

public class Reminder1{

   public void printReminder(){

   }
}


The actual data processing is effected between the curly parenthesises "{" and "}" in the body of printReminder().

To hold the value of the number of days to pay the amount declare a constant inside Reminder1 (before the method printReminder()):
  byte numberDays = 14;

The first sentences inside printReminder() will look like this:
   System.out.println("To Javan Wonder");

Write the remaining lines yourself, remember to use numberDays in the code !
Remember to add a sentence stating the sender.

Use the menu Tools -> Compile Java (CTRL+1) to compile the class.
When compiled correct use File -> Save as to save the class in the file Reminder1.java.

Now create a class - ReminderApp - to run your Reminder1-application, activating the method printReminder():

  public class ReminderApp {
    public static void main(String[] args) {

       //create an object of the Reminder1-class:
      Reminder1 reminder = new Reminder1();
      //activate the printReminder-method in this object:
      reminder.printReminder();
    }
  }

Save this class in the file ReminderApp.java.
Finally use the menu Tools -> Run Java Application (CTRL+2) to run the program.

Assignment 2
This reminder should be applied to other debtors, who all owe the same amount.
The class Reminder1 must be changed so that the receiver is not fixed but a variable.

Open the Reminder1.java file and save it in another file - Reminder2.java (use File -> Save as).
As it's just another version you could save it in the existing folder Reminder.
Remember to change the name of the class to Reminder2 (so it has the exact same name as the file).

Declare a string variable, receiver, to hold the name of the receiver just after the declaration of numberDays;

The start of the method should now contain a sentence, which reads the name of the reciever (remember to import javax.swing.JOptionPane;):

  receiver = JOptionPane.showInputDialog("Enter reciever :");

and the first print statement is to use this value:

  System.out.println("To " + receiver);

Compile the new class.
Open ReminderApp.java and change it so it creates an object of the Reminder2 class (instead of Reminder1).

Compile and run ReminderApp.


Assignment 3
Rewrite the class
Reminder2, so that a variable sender name can be used and so that the amount is not a literal, but a constant.
Save the new version of the class in a new file
Reminder3.java
Remember to change the class-name to
Reminder3.

Make the necesarry changes in ReminderApp, compile and run the program.