Write a RMI based application which takes your marks of six subjects from the client side and displays the percentage that you have obtained.
---------------------------------------------------------------------------------- Interface ---------------------------------------------------------------------------------- publicinterface perInterface extends java.rmi.Remote { float find_per(int marks[]) throws java.rmi.RemoteException; } ------------------------------------------------------------------------------------------------- Implementation ------------------------------------------------------------------------------------------------- import java.rmi.*; import java.rmi.registry.*; import java.rmi.server.UnicastRemoteObject; publicclass perImpl extends UnicastRemoteObject implements perInterface { public perImpl(String name) throws RemoteException { super(); try { Naming.rebind(name,this); } catch(Exception e) { System.out.println("Exception:"+ e.getMessage()); e.printStackTrace(); } } publicfloat find_per(int marks[]) throws RemoteException { int sum=0; float per; for(int counter=0;counter < marks.length;counter++) sum+=marks[counter]; per = (float)sum/3; return per; } } ------------------------------------------------------------------------------------------------- Client ------------------------------------------------------------------------------------------------- import java.rmi.*; import java.rmi.registry.*; import java.rmi.server.*; import java.io.*; publicclass perClient { publicstaticvoid main(String args[]) { System.setSecurityManager(new RMISecurityManager()); try { float percentage=0; int marks[]=newint[6]; perInterface pi = (perInterface) Naming.lookup("//localhost/pno"); BufferedReader ber=new BufferedReader(new InputStreamReader(System.in)); String temp=new String(); for(int counter=0;counter<6;counter++) { System.out.print("\n Enter Marks For Subject " + (counter+1) + " : "); temp=ber.readLine(); marks[counter]=Integer.parseInt(temp); } percentage = pi.find_per(marks); System.out.println("Percentage is : " + percentage); } catch(Exception e) { System.out.println("System Exception" + e); } } } ------------------------------------------------------------------------------------------------- Server ------------------------------------------------------------------------------------------------- import java.rmi.*; import java.rmi.registry.*; import java.rmi.server.*; publicclass perServer { publicstaticvoid main(String args[]) { System.setSecurityManager(new RMISecurityManager()); try { perImpl pim = new perImpl("//localhost/pno"); System.out.println("\nServer is ready..."); } catch(Exception e) { System.out.println("Exception: " + e.getMessage()); e.printStackTrace(); } } } ------------------------------------------------------------------------------------------------- Policy ------------------------------------------------------------------------------------------------- grant { // Allow everything for now permission java.security.AllPermission; }; ---------------------------------------------------------------------------------- Output ---------------------------------------------------------------------------------- Enter Marks For Subject 1 : 30 Enter Marks For Subject 2 : 25 Enter Marks For Subject 3 : 28 Enter Marks For Subject 4 : 21 Enter Marks For Subject 5 : 29 Enter Marks For Subject 6 : 22 Percentage is : 51.666668