Sei sulla pagina 1di 23

ESCUELA MILITAR DE INGENIERA MARISCAL ANTONIO JOS DE SUCRE BOLIVIA

SISTEMAS DISTRIBUIDOS
NOMBRE:
Khendy Chavez Ramirez Melisa Ticona Mujica

PARALELO:
OCTAVO SEMESTRE

CARRERA:
ING. SISTEMAS

FECHA:
11-04-2013

LA PAZ BOLIVIA

ESCUELA MILITAR DE INGENIERA MARISCAL ANTONIO JOS DE SUCRE BOLIVIA

PROBLEMAS 4 Y 5 Problema 4:
Pollos Copacabana Se realiza un sistema para calcular el pago de salario para una empresa

Tomando ejemplo

Lunes Das Lunes Martes Mircoles Jueves Viernes Sbado Domingo Suma Total 7 9 10 5 3 1 8 31 W 7 8 8 5 3 1 3 12 1 2 E

Salario Normal: 310 Salario Extra: 180 RESUMEN

ESCUELA MILITAR DE INGENIERA MARISCAL ANTONIO JOS DE SUCRE BOLIVIA Horas semanales: 31*10 Horas extras: Total: 43 Las Tareas EXTRA NORMAL son 10 bs/hora 15 bs/hora Horarios 8 hrs(lunes-viernes) Hrs extra(sbado domingo) 12*15

Procesos que se realizo 1) El primera paso es crear el archivo PollosCopacabana.java, y despus generamos su .class con el comando javac *.java desde la lnea de comandos 2) El segundo paso es crear el archivo CalculatorImpl.java, generamos su .class. 3) El tercer paso es crear el archivo CalculatorCServer.java, generamos su .class 4) Por ltimo creamos el archivo PollosCCliente.java de igual forma generamos su .class 5) Utilizando el ejemplo del anterior clase calculadora se usa los comandos para hacer la respectiva ejecucin. 6) Imgenes del corrido

Para ejecutar el ejercicio entramos al smbolo del sistema.

ESCUELA MILITAR DE INGENIERA MARISCAL ANTONIO JOS DE SUCRE BOLIVIA

Ingresamos a la ruta donde est guardado nuestro programa.

C:\Sun\SDK\jdk\bin para ubicarse en el directorio donde estn todos los archivos .java

ESCUELA MILITAR DE INGENIERA MARISCAL ANTONIO JOS DE SUCRE BOLIVIA

Escribimos C:\Sun\SDK\jdk\bin>javac *.java para generar los archivos .class de todos los archivos .java

ESCUELA MILITAR DE INGENIERA MARISCAL ANTONIO JOS DE SUCRE BOLIVIA

ESCUELA MILITAR DE INGENIERA MARISCAL ANTONIO JOS DE SUCRE BOLIVIA

Ejecutado el Cliente se procede a emplear el sistema para realizar el pedido:

ESCUELA MILITAR DE INGENIERA MARISCAL ANTONIO JOS DE SUCRE BOLIVIA

Cdigo:

import java.rmi.Naming; import java.rmi.RemoteException; import java.net.MalformedURLException; import java.rmi.NotBoundException; import java.io.*; import java.util.*; public class PollosCopacabana { public static void main(String[] args)throws Exception { BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); int num; try { Calculator c = (Calculator) Naming.lookup("rmi://localhost/CalculatorService"); int N=0,E1=0,E2=0,E3=0,E4=0,E5=0,E6=0,E7=0; System.out.println("******HORAS TRABAJADAS DE EMPLEADOS******");

ESCUELA MILITAR DE INGENIERA MARISCAL ANTONIO JOS DE SUCRE BOLIVIA System.out.println("Lunes:....."); int a=Integer.parseInt(in.readLine()); if(a <= 8){N=N+a;} else{E1=(a-8); N=N+8;} System.out.println("Martes:....."); int b=Integer.parseInt(in.readLine()); if(b <= 8){N=N+b;} else{E2=(b-8); N=N+8;} System.out.println("Miercoles:......"); int h=Integer.parseInt(in.readLine()); if(h <= 8){N=N+h;} else{E3=(h-8); N=N+8;} System.out.println("Jueves:......"); int d=Integer.parseInt(in.readLine()); if(d <= 8){N=N+d;} else{E4=(d-8); N=N+8;} System.out.println("Viernes:....."); int e=Integer.parseInt(in.readLine()); if(e <= 8){N=N+e;} else{E5=(e-8); N=N+8;} System.out.println("Sabado:....."); int f=Integer.parseInt(in.readLine()); E6=f; System.out.println("Domingo:......."); int g=Integer.parseInt(in.readLine()); E7=g; //Suma de horas extra int E = E1 + E2 + E3 + E4 + E5 + E6 + E7; System.out.println("Salario Normal del empleado:"); int SN = N*10; System.out.println(SN); System.out.println("Salario Extra del empleado:"); int SE = E*15; System.out.println(SE);

ESCUELA MILITAR DE INGENIERA MARISCAL ANTONIO JOS DE SUCRE BOLIVIA System.out.println("Resumen de salario normal y salario extra:"); int RE = SN+SE; System.out.println(RE); System.out.println("Horas Normal:"); System.out.println(N); System.out.println("Horas Extra:"); System.out.println(E); System.out.println("TOTAL DE HORAS:...."); int TH = N+E; System.out.println(TH); } 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);} } }

ESCUELA MILITAR DE INGENIERA MARISCAL ANTONIO JOS DE SUCRE BOLIVIA

PROBLEMA 5 Realizar una aplicacin para la Cafetera EMI

OPCION 1

MENU: cafs 1 Cafecito 2 Capuchino 3 Gaseosa 4 nada

OPCION 2

MENU: Helados 1 Helado Simple 2 De Vaso 3 Helado Especial 4 nada

ESCUELA MILITAR DE INGENIERA MARISCAL ANTONIO JOS DE SUCRE BOLIVIA

OPCION 3

MENU: Sndwiches 1 De Queso y Huevo 2 De Carne Doble 3 De Carne y Huevo 4 nada

OPCION 4

MENU: Platos 1 Plato Silpancho 2 Pollo Frito 3 Salchipapa 4 nada

ESCUELA MILITAR DE INGENIERA MARISCAL ANTONIO JOS DE SUCRE BOLIVIA Pedido

Procesos que se realizo 1) El primera paso es crear el archivo Cafeteria_EM1.java, y despus generamos su .class con el comando javac *.java desde la lnea de comandos 2) El segundo paso es crear el archivo CalculatorImpl.java, generamos su .class. 3) El tercer paso es crear el archivo CalculatorCServer.java, generamos su .class 4) Por ltimo creamos el archivo Cafeteria_EM1.java de igual forma generamos su .class 5) Utilizando el ejemplo del anterior clase calculadora se usa los comandos para hacer la respectiva ejecucin. 6) Imgenes del corrido

Para ejecutar el ejercicio entramos al smbolo del sistema.

Ingresamos a la ruta donde est guardado nuestro programa.

ESCUELA MILITAR DE INGENIERA MARISCAL ANTONIO JOS DE SUCRE BOLIVIA

C:\Sun\SDK\jdk\bin para ubicarse en el directorio donde estn todos los archivos .java

Escribimos C:\Sun\SDK\jdk\bin>javac *.java para generar los archivos .class de todos los archivos .java

ESCUELA MILITAR DE INGENIERA MARISCAL ANTONIO JOS DE SUCRE BOLIVIA

ESCUELA MILITAR DE INGENIERA MARISCAL ANTONIO JOS DE SUCRE BOLIVIA

ESCUELA MILITAR DE INGENIERA MARISCAL ANTONIO JOS DE SUCRE BOLIVIA

ESCUELA MILITAR DE INGENIERA MARISCAL ANTONIO JOS DE SUCRE BOLIVIA

Cdigo: import java.rmi.Naming; import java.rmi.RemoteException; import java.net.MalformedURLException; import java.rmi.NotBoundException; import java.io.*; public class Cafeteria_EM1{ public static void main(String[] args) throws Exception{ BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); int suma, tb,b,cb, th,h,ch, ts,s,cs, tp,p,cp; suma=0; try { Calculator c = (Calculator) Naming.lookup("rmi://localhost/CalculatorService"); //Solicitud de productos System.out.println("*********Cafeteria EMI *************"); System.out.println("Bebidas:"); System.out.println("Descripcion \t Cantidad"); System.out.println("1 Cafecito \t\t 3"); System.out.println("2 Capuchino \t 3");

ESCUELA MILITAR DE INGENIERA MARISCAL ANTONIO JOS DE SUCRE BOLIVIA System.out.println("3 Gaseosa \t\t 5"); System.out.println("0 nada"); System.out.print("Opcion:............. "); b = Integer.parseInt(in.readLine()); cb=0; if(b > 0 && b<4 ){ System.out.print("Cantidad: "); cb=Integer.parseInt(in.readLine()); } System.out.println("********"); System.out.println("Helados:"); System.out.println("Descripcion \t Cantidad"); System.out.println("************"); System.out.println("1 Helado Simple \t 8"); System.out.println("2 De Vaso \t\t 12 "); System.out.println("3 Helado Especial \t 22"); System.out.println("0 nada"); System.out.print("Opcion:............. "); h = Integer.parseInt(in.readLine()); ch=0; if(h > 0 && h<4 ){ System.out.print("Cantidad: "); ch=Integer.parseInt(in.readLine()); } System.out.println("***********"); System.out.println("Sandwiches:"); System.out.println("Descripcion \t Cantidad"); System.out.println("**************"); System.out.println("1 De Queso y Huevo \t 15"); System.out.println("2 De Carne Doble \t 20"); System.out.println("3 De Carne y Huevo \t 15"); System.out.println("0 nada"); System.out.print("Opcion:............. "); s = Integer.parseInt(in.readLine()); cs=0; if(s > 0 && s<4 ){ System.out.print("Cantidad: "); cs=Integer.parseInt(in.readLine()); }

ESCUELA MILITAR DE INGENIERA MARISCAL ANTONIO JOS DE SUCRE BOLIVIA

System.out.println("Platos:"); System.out.println("******"); System.out.println("Descripcion \t Cantidad"); System.out.println("*******"); System.out.println("1 Plato Silpancho \t 25"); System.out.println("2 Pollo Frito \t 20"); System.out.println("3 Salchipapa \t 6"); System.out.println("0 nada"); System.out.print("Opcion:.......... "); p = Integer.parseInt(in.readLine()); cp=0; if(p > 0 && p<4 ){ System.out.print("Cantidad: "); cp=Integer.parseInt(in.readLine()); } //pedidoo System.out.println("----Pedido----"); System.out.println("Cant \t Descuento \t Precio"); suma=suma+menuBebida(b,cb); suma=suma+menuHelados(h,ch); suma=suma+menuSandwiches(s,cs); suma=suma+menuPlatos(p,cp); System.out.println("TOTAL:............\t\t"+suma);

} 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);}

ESCUELA MILITAR DE INGENIERA MARISCAL ANTONIO JOS DE SUCRE BOLIVIA catch (java.lang.ArithmeticException ae) { System.out.println(); System.out.println("java.lang.ArithmeticException"); System.out.println(ae);} } // public static int menuBebida (int b, int cb){ int tb=0; switch (b) { case 1: tb=cb*3; System.out.println(cb + "\tCafecito \t\t" + tb); break; case 2: tb=cb*5; System.out.println(cb + "\tCapuchino \t" + tb); break; case 3: tb=cb*2; System.out.println(cb + "\tGaseosa \t" + tb); break; default: tb=0; } return tb; } public static int menuHelados (int b, int cb){ int tb=0; switch (b) { case 1: tb=cb*3; System.out.println(cb + "\tHelado Simple \t\t" + tb); break; case 2: tb=cb*7; System.out.println(cb + "\tDe Vaso \t\t" + tb); break; case 3: tb=cb*15; System.out.println(cb + "\tHelado Especial \t" + tb);

ESCUELA MILITAR DE INGENIERA MARISCAL ANTONIO JOS DE SUCRE BOLIVIA break; default: tb=0; } return tb; } public static int menuSandwiches(int b, int cb){ int tb=0; switch (b) { case 1: tb=cb*7; System.out.println(cb + "\tDe Queso y Huevo\t" + tb); break; case 2: tb=cb*5; System.out.println(cb + "\tDe Carne Doble \t\t" + tb); break; case 3: tb=cb*5; System.out.println(cb + "\tDe Carne y Huevo \t\t" + tb); break; default: tb=0; } return tb;} public static int menuPlatos(int b, int cb){ int tb=0; switch (b) { case 1: tb=cb*12; System.out.println(cb + "\tPlato Silpancho \t" + tb); break; case 2: tb=cb*20; System.out.println(cb + "\tPollo Frito \t" + tb); break; case 3: tb=cb*7; System.out.println(cb + "\tSalchipapa \t" + tb); break; default: tb=0; } return tb;

ESCUELA MILITAR DE INGENIERA MARISCAL ANTONIO JOS DE SUCRE BOLIVIA } }

Potrebbero piacerti anche