Create the client-server system using RMI with port number 9000. When the connection is established, the client interacts with the user to get an input integer and sends the integer to the server. The server accepts this number, calculates its factorial, and sends the result back to the client.

Write two programs: one for the client side and one for the server side.



Answer :

Final answer:

Explanation of creating a client-server system using RMI for factorial calculation.


Explanation:

Client Side Program

import java.rmi.;
import java.rmi.registry.
;
import java.util.Scanner;

public class Client {
public static void main(String[] args) {
try {
Registry reg = LocateRegistry.getRegistry('127.0.0.1', 9000);
FactorialInterface factorial = (FactorialInterface) reg.lookup('Factorial');
Scanner scanner = new Scanner(System.in);
System.out.println('Enter an integer:');
int num = scanner.nextInt();
int result = factorial.calculateFactorial(num);
System.out.println('Factorial of ' + num + ' is ' + result);
} catch (Exception e) {
System.out.println(e);
}
}

}

Server Side Program

public class Server implements FactorialInterface {
public int calculateFactorial(int num) {
int fact = 1;
for (int i = 1; i <= num; i++) {
fact *= i;
}
return fact;
}
}


Learn more about Remote Method Invocation (RMI) here:

https://brainly.com/question/13641616