Laboratorio N°2: Nombre CI
Laboratorio N°2: Nombre CI
Laboratorio N°2: Nombre CI
LABORATORIO N°2
RMI_calculadora
Clase cliente.java
/*
*/
package RMI_Calculadora;
import javax.swing.JOptionPane;
import java.rmi.registry.Registry;
import java.rmi.registry.LocateRegistry;
import java.util.Scanner;
import java.rmi.Naming;
/**
* @author Once
*/
try{
calculadora c = (calculadora)Naming.lookup("//localhost/calculadora");
while(true)
+"Ingrese (1)......SUMA\n"
+"Ingrese (2)......RESTA\n"
+"Ingrese (3)......MULTIPLICACION\n"
+"Ingrese (4)......DIVICION\n"
+"Ingrese (5)......POTENCIAS\n"
+"Ingrese (6)......MODULO\n"
+"Ingrese (7)......SENO\n"
+"Ingrese (8)......COSENO\n"
+"Ingrese (9)......RAIZ\n"
switch(menu)
case "1":
double y = Integer.parseInt(JOptionPane.showInputDialog("Ingrese el
segundo numero a sumar"));
break;
case "2":
double y = Integer.parseInt(JOptionPane.showInputDialog("Ingrese el
segundo numero a restar"));
break;
}
case "3":
double y = Integer.parseInt(JOptionPane.showInputDialog("Ingrese el
segundo numero a multiplicacion"));
break;
case "4":
double y = Integer.parseInt(JOptionPane.showInputDialog("Ingrese el
segundo numero a dividir"));
break;
case "5":
double y = Integer.parseInt(JOptionPane.showInputDialog("Ingrese el
exponente"));
break;
}
case "6":
break;
case "7":
double x = Integer.parseInt(JOptionPane.showInputDialog("Ingrese el
angulo"));
break;
case "8":
double x = Integer.parseInt(JOptionPane.showInputDialog("Ingrese el
angulo"));
break;
case "9":
{
double x = Integer.parseInt(JOptionPane.showInputDialog("Ingrese la base"));
break;
Clase Mrmi.java
/*
*/
package RMI_Calculadora;
import java.rmi.server.UnicastRemoteObject;
import java.rmi.RemoteException;
/**
* @author Once
*/
public class Mrmi extends UnicastRemoteObject implements calculadora {
double a,b;
@Override
return a+b;
@Override
return a-b;
@Override
return a*b;
@Override
return a/b;
@Override
public double pot(double a, double b) throws RemoteException
return Math.pow(a,b);
@Override
return a%b;
@Override
return Math.sin(a);
@Override
return Math.cos(a);
@Override
return Math.pow(a,1/b);
}
Clase Servidor.java
/*
*/
package RMI_Calculadora;
import javax.swing.JOptionPane;
import java.rmi.registry.Registry;
/**
* @author Once
*/
try
Registry r = java.rmi.registry.LocateRegistry.createRegistry(1099);
r.rebind("calculadora",new Mrmi());
}
calculadora.java
/*
*/
package RMI_Calculadora;
import java.rmi.Remote;
import java.rmi.RemoteException;
/**
* @author Once
*/