JAVA
java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
public class MailingSystem {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
String name = null;
String oldAddress = null;
String newAddress = null;
boolean result;
MailForwardingSystem mailSystem = new MailForwardingSystem();
//Create the scanner object for user input
Scanner keyboard = new Scanner(System.in);
String choice = keyboard.nextLine();
//It will keep looping until the user command to quit
while(!choice.equals("QUIT")) {
switch (choice) {
case "ADD":
//Call the add method
result = mailSystem.add(name, oldAddress, newAddress);
if (result == true) {
//If addded successully, it will print out "ADDED"
System.out.println("ADDED");
} else {
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run