Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

For this assignment, you will be creating an RMI application. Starting the appli

ID: 3912310 • Letter: F

Question

For this assignment, you will be creating an RMI application. Starting the application includes running the RMI remote object registry, the server, and the client.

After implementing the sample RMI program in the link here: https://docs.oracle.com/javase/tutorial/rmi/overview.html , create a simple remote calculator application based on the PI calculator in the tutorial. Your calculator should implement the following remote methods:

double add(double operand1, double operand2)

double subtract(double operand1, double operand2)

double multiply(double operand1, double operand2)

double divide(double operand1, double operand2)

Explanation / Answer

//Calculator.java

}

//CalculatorClient.java

public static void main(String[] args) {

System.out.println("Enter the operands")

Scanner sc=new Scanner(System.in);

///CalculatorImpl.java

//CalculatorServer.java

}

//Compile all the *.java files

//run registry

//run server

//run client

public interface Calculator extends java.rmi.Remote { public long add(long a, long b) throws java.rmi.RemoteException; public long sub(long a, long b) throws java.rmi.RemoteException; public long mul(long a, long b) throws java.rmi.RemoteException; public long div(long a, long b) throws java.rmi.RemoteException;

}

//CalculatorClient.java

import java.rmi.Naming; import java.rmi.RemoteException; import java.net.MalformedURLException; import java.rmi.NotBoundException; public class CalculatorClient {

public static void main(String[] args) {

System.out.println("Enter the operands")

Scanner sc=new Scanner(System.in);

long num1 = sc.nextLong(); long num2 = sc.nextLong(); try { Calculator c = (Calculator) Naming.lookup("rmi://localhost/CalculatorService"); System.out.println( "The substraction of "+num1 +" and "+num2 +" is: "+ c.sub(num1, num2) ); System.out.println( "The addition of "+num1 +" and "+ num2 +"is: "+c.add(num1, num2) ); System.out.println( "The multiplication of "+num1 +" and "+num2 +" is: "+c.mul(num1, num2) ); System.out.println( "The division of "+num1 +" and "+ num2 +"is: "+c.div(num1, num2) ); } catch (MalformedURLException murle) { System.out.println(); System.out.println("MalformedURLException"); System.out.println(murle); } catch (RemoteException re) { System.out.println(); System.out.println("RemoteException"); System.out.println(re); } catch (NotBoundException nbe) { System.out.println(); System.out.println("NotBoundException"); System.out.println(nbe); } catch (java.lang.ArithmeticException ae) { System.out.println(); System.out.println("java.lang.ArithmeticException"); System.out.println(ae); } } }
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote