@@ -0,0 +1,1876 @@
+package Main;%0Aimport java.util.Random;%0A/* %0AEnhanced and optimized for Moodfinder application by Amin Amini Maghsoud Bigy: 2012%0A*/%0Apublic class Moodfinder %7B%0A    //These correspond to the states of Manager.%0A    private static final int START = 0;%0A    private static final int CALCULATE = 1;%0A    private static final int ANSWER = 2;%0A    public int firstNum=0;%0A%09  public int SecondNum=0;%0A    /* Variable declarations */%0A    private int state = START;%0A    public int Client_answer=0;%0A    /* The processInput method */%0A    %09public String processInput(String theInput) %7B%0A    %09%09String theOutput = null;%0A    %09%09Random diceRoller = new Random();  %09%0A    %09%09switch (state)%7B%0A    %09%09case START:%0A    %09%09%09//Prompting user to start the Moodfinder process.%0A    %09%09%09%0A    %09%09%09theOutput = %22Do you want to start the process? YES/NO%22;%0A    %09%09%09%0A    %09%09%09state = CALCULATE;%0A    %09%09%09break;%0A    %09%09case CALCULATE:%0A    %09%09%09//Check to see if the TOTAL reaches the goal.%0A    %09%09%09if (Manager.total %3E= 2000000) %7B%0A    %09%09%09%09theOutput = %22END%22;%09%0A    %09%09%09%7D else %7B%0A    %09%09%09if (theInput.equalsIgnoreCase(%22yes%22)) %7B%0A    %09%09%09%09//Generate two random numbers and send them to the Worker.%0A    %09%09    %09%09  firstNum = diceRoller.nextInt(20) + 1;%0A    %09%09    %09%09  SecondNum = diceRoller.nextInt(40) + 1;%0A    %09%09    %09%09  theOutput = firstNum+%22*%22+SecondNum;%0A    %09%09    %09%09  state = ANSWER;%0A    %09%09%09%7D %0A    %09%09%09else if(theInput.equalsIgnoreCase(%22No%22))%7B%0A    %09%09%09%09theOutput = %22END%22;%0A    %09%09%09%7D%0A    %09%09%09%7D%09%09%0A    %09%09%09break;%0A    %09%09case ANSWER:%0A    %09%09%09//Convert the results coming from Worker back into Integer%0A    %09%09%09Client_answer = Integer.parseInt(theInput);%0A    %09%09    //Add the results coming from Worker to the Total%0A    %09%09%09Manager.total += Client_answer;%09%0A%09%09%09%09theOutput = %22     Target:%22 +Manager.total;%0A%09%09%09%09state = CALCULATE;%0A%09%09%09%09%09break;%09%09%0A    %09%09%7D%0A    %09%09//Once we have the output message, pass it back to Server.%0A    %09%09return theOutput;%0A    %09%7D%0A    %09%0A    %09%7D%0A    %09%0A

Create Moodfinder.java