Reference another EJB from an EJB (on) -4

zhaozj2021-02-16  44

Fill in the test code: (black body part)

Package compoundinterestage;

Import java.io. *;

Import javax.naming. *;

Import java.util.properties;

Import javax.rmi.portableremoteObject;

Import java.rmi.remoteexception;

Public Class CompoundinterestAgentTestClient

{

Private static final string error_null_remote = "Remote Interface Reference Is Null. It must be create by calling one of the home interface method method.";

PRIVATE STATIC FINAL INT MAX_OUTPUT_LINE_LENGTH = 100;

PRIVATE BOOLEAN Logging = True;

Private CompoundinterestAgerthome CompoundINTERESTAGENTHOME = NULL;

Private compoundINTERESTAGENT COMPoundINTERESTAGENT = NULL;

Private static bufferedreader in;

..................

Private static string getInputString (String Prompt) THROWS IOEXCEPTION

{

System.out.println (Prompt);

Return in.readline ();

}

// main Method

Public static void main (string [] args)

{

CompoundINTERESTAGENTTSTCLIENT Client = New CompoundINTERESTAGENTTESTSTCLIENT ();

CompoundINTERESTAGENT AGENT;

Boolean Valid;

String answer;

Double tmpdbl = 0.0;

INT tmpint = 0;

IN = New BufferedReader (NEW INPUTSTREAMREADER (System.in));

Try

{

Agent = Client.create ();

System.out.println ("/ NWELCOME TO The Compound Interest Calculation:");

DO

{

Answer = GetInputString ("Enter A Starting Balance: $");

Try

{

TMPDBL = double.PARSEDOUBLE (ANSWER);

Agent.setstartingbalance (TMPDBL);

VALID = TRUE;

} catch (NumberFormatexception NFE)

{

System.out.Println ("Invalid Entry!");

Valid = false;

}

} while (valid == false);

DO

{

System.out.Println ("How offen will the intert company);

Answer = getInputString ("(1) Monthly, (2) quertry, (3) Semi_annually"); TRY

{

TMPINT = Integer.Parseint (Answer);

IF (TMPINT> 3)

Throw new NumberFormatexception ();

Agent.SetFrequency (TMPINT);

VALID = TRUE;

} catch (NumberFormatexception NFE)

{

System.out.Println ("Invalid Entry!");

Valid = false;

}

} while (valid == false);

DO

{

System.out.Println ("How much will you be controling"); "" HOW MUCH WIOUTY

Switch (TMPINT)

{

Case 1:

Answer = GetInputString ("Each Month?");

Break;

Case 2:

Answer = GetInputString ("EACH quarter?");

Break;

Case 3:

Answer = GetInputString ("EVERY SIX MONTH?");

Break;

}

Try

{

TMPDBL = double.PARSEDOUBLE (ANSWER);

Agent.SetContribution (TMPDBL);

VALID = TRUE;

} catch (NumberFormatexception NFE)

{

System.out.Println ("Invalid Entry!");

Valid = false;

}

} while (valid == false);

DO

{

Answer = GetInputString ("What is The ammount's annual yield?");

Try

{

TMPDBL = double.PARSEDOUBLE (ANSWER);

Agent.setanNualyIELD (TMPDBL);

VALID = TRUE;

} catch (NumberFormatexception NFE)

{

System.out.Println ("Invalid Entry!");

Valid = false;

}

} while (valid == false);

DO

{

Answer = GetInputString ("How Many Years Will You Maintain This Account?");

Try

{

TMPINT = Integer.Parseint (Answer);

Agent.SetTime (TMPINT);

VALID = TRUE;

} catch (NumberFormatexception NFE)

{

System.out.Println ("Invalid Entry!");

Valid = false;

}

} while (valid == false);

DO

{

Answer = GetInputString ("What Rate of Inflation Rate Are You Anticipating?");

Try

{

TMPDBL = double.PARSEDOUBLE (ANSWER);

Agent.setInflation (TMPDBL);

VALID = TRUE;

} catch (NUMBERFORMATEXCEPTION NFE) {

System.out.Println ("Invalid Entry!");

Valid = false;

}

} while (valid == false);

TMPDBL = agent.calculatereturn ();

System.out.println ("The Return On this Account Would BE $" TMPDBL;

} catch (RemoteException RE)

{

Re.printStackTrace ();

} catch (ioexception ie)

{

IoE.PrintStackTrace ();

} catch (Exception E)

{

E.PrintStackTrace ();

}

}

}

转载请注明原文地址:https://www.9cbs.com/read-26326.html

New Post(0)