SINTAXIS DE UN CELULAR CON JAVA ECLIPSE

Page 1

PRIMERA CLASE DE LA CALCULADORA

}

public class calculadora{ private int a; private int b; private int res; private int sum; private int mul; private double div;

public void multi (){ mul = a*b; } public int getmul (){ return mul; } public void div (){ div = a/b; } public double getdiv (){ return div; }

public void seta (int x){ a = x; } public void setb (int x){ b = x; } public int geta (){ return a; } public int getb (){ return b; } public void suma (){ sum = a+b; } public int getsum (){ return sum; } public void resta (){ res = a-b; } public int getres (){ return res;

HECTOR CAMPOS ALONSO

public void setllamadas(String x){ llamadas=llamadas+" \n "+x; saldo=saldo-4; } public double setsaldo(){ return saldo; } public void setfecha(char x){ fecha= x; } public void sethora(int

} PRIMERA CLASE DEL CELULAR

public class celular extends cientifica { private String msj; private String llamadas; private char fecha; private int hora; private double saldo; private int day; private int mes; private int anio; private int minutos; public void fijarmsj(String x){ msj=x; saldo=saldo-0.90; }

x){ hora=x; } public void setsaldo(double x){ saldo=saldo+ x; } public String getmsj(){ return msj; } public String getllamadas(){ return llamadas; } public char getfecha(){ return fecha; } public int gethora(){ return hora; } public double getsaldo(){ return saldo;

Pรกgina 1


} public void setday (int x){ day = x; } public int getday (){ return day; } public void setmes (int x){ mes = x; } public int getanio(){ return anio; } public void setanio (int x){ anio = x; } public int getmes(){ return anio; } public void setminutos(int x){ minutos = x; } public int getminutos (){ return minutos; } } SEGUNDA CLASE DE LA CALCULADORA

HECTOR CAMPOS ALONSO

public class cientifica extends calculadora { private int factorial; private double raiz; private int potencia; private int modulo ; public void setraiz (){ raiz = Math.sqrt(geta()); } public double raiz (){ return raiz; } public void setpotencia (){ potencia = (int)Math.pow (geta()+getb(),potencia); } public double potencia (){ return potencia;

public class conatactos{ private int telefono; private String msj; public void settelefono(int x){ telefono = x; } public int gettelefono (){ return telefono; } public void setmsj (String x){ msj =x; } public String getmsj (){ return msj; } }

} SEGUNDA CLASE DEL CELULAR public void setmodulo (){ modulo =geta()% getb(); } public int getmodulo (){ return modulo; } public int getfactorial (){ return factorial; } }

import javax.swing.*; public class manejador extends main { public static void main(String[] args) { celular ops = new celular (); int h; int x; double fijarsaldo=100; do{

Pรกgina 2


h = Integer.parseInt(JOptionPane.sho wInputDialog(null,"============= ================================ ======\n QUE OPERACIONES QUIERES REALIZAR\n====================== =============================\n 1: PEDIR SALDO\n ================================ ===================\n 2: ENVIAR UN MENSAJE \n============================== =====================\n 3: PARA REALIZAR UNA LLAMADA\n======================= ============================\n 4:AJUSTES=\n==================== ===============================\ n 5:APAGAR CELULAR\n"+"==================== ===============================" )); switch (h){ case 1: int j; do{ j = Integer.parseInt(JOptionPane.sho wInputDialog(null,"QUE OPERACIONES QUIERES REALIZAR\n 1: INGRESA SALDO \n 2: CONSULTAR SALDO \n 3:REGRESAR AL MENU \n")); switch (j){ case 1: ops.setsaldo(Double.parseD ouble(JOptionPane.showInputDialo

HECTOR CAMPOS ALONSO

g(null,"CUANTO QUIERE RECARGAR"))); break; case 2: JOptionPane.showMessageDia log(null, ops.getsaldo()); break; case 3: JOptionPane.showMessageDia log(null,"REGRESANDO AL MENU "); break; } }while (j!=3); } switch (h){ case 2: int f; do{ f = Integer.parseInt(JOptionPane.sho wInputDialog(null,"QUE OPERACIONES QUIERES REALIZAR\n 1: INGRESA MENSAJE \n 2: MOSTRAR MENSAJES \n 3:REGRESAR AL MENU \n")); switch (f){ case 1: ops.fijarmsj(JOptionPane.s howInputDialog(null,"ESCRIBE EL TEXTO")); if (fijarsaldo>=1.00){

JOptionPane.showMessageDia log(null,"ENVIAR MENSAJE"); JOptionPane.showMessageDia log(null,"MENSAJE ENVIADO EXITOSAMENTE "); }else{ JOptionPane.showMessageDia log(null,"NO HAY SUFICIENTE SALDO PARA ENVIAR MENSAJE"); } break; case 2: JOptionPane.showMessageDia log(null, ops.getmsj()); break; case 3: JOptionPane.showMessageDia log(null,"REGRESANDO AL MENU "); break; } }while (f!=3); } switch (h){ case 3: int s; do{

Pรกgina 3


s = Integer.parseInt(JOptionPane.sho wInputDialog(null,"QUE OPERACIONES QUIERES REALIZAR\n 1: REALIZAR LLAMADA \n 2: MOSTRAR LLAMADAS REALIZADAS \n 3:REGRESAR AL MENU \n")); switch (s){ case 1: ops.setllamadas(JOptionPan e.showInputDialog(null,"TECLEA EL NUMERO")); if (fijarsaldo>=4.00){ JOptionPane.showMessageDia log(null,"REALIZAR LA LLAMADA "); }else{ JOptionPane.showMessageDia log(null,"NO HAY SUFICIENTE SALDO PARA REALIZAR TU LLAMADA"); break;

JOptionPane.showMessageDia log(null,"REGRESANDO AL MENU "); } }while (s!=3); } switch (h){ case 4: int a; do{ a = Integer.parseInt(JOptionPane.sho wInputDialog(null,"QUE OPERACIONES QUIERES REALIZAR\n 1: AJUSTAR FECHA \n 2: MOSTRAR FECHA \n 3:AJUSTAR HORA\n 4:MOSTRAR HORA \n 5:CALCULADORA\n 6: REGRESAR AL MENU \n")); switch (a){ case 1: ops.setday(Integer.parseIn t(JOptionPane.showInputDialog(nu ll,"INGRESA EL DIA DE HOY"))); ops.getday();

} case 2: JOptionPane.showMessageDia log(null,"EL NUMERO QUE MARCASTES ES :"+ ops.getllamadas()); break; case 3:

HECTOR CAMPOS ALONSO

ops.setmes(Integer.parseIn t(JOptionPane.showInputDialog(nu ll,"INGRESA EL MES ACTUAL"))); ops.getmes(); ops.setanio(Integer.parseInt(JOp tionPane.showInputDialog(null,"I NGRESA EL Aテ前 ACTUAL ")));

ops.getanio(); JOptionPane.showMessageDia log(null,"HAS COMPLETADO CORRECTAMENTE LOS AJUSTES "); break; case 2: JOptionPane.showMessageDia log(null ,ops.getday()+"/ "+ops.getmes()+"/"+ops.getanio() ); JOptionPane.showConfirmDia log(null, ops.getday()+"/ "+ops.getmes()+"/"+ops.getanio() ); break; case 3: ops.sethora(Integer.parseInt(JOp tionPane.showInputDialog(null,"H ORA "))); ops.gethora(); ops.setminutos(Integer.parseInt( JOptionPane.showInputDialog(null ,"MINUTOS"))); ops.getminutos(); JOptionPane.showMessageDia log(null,"HAS COMPLETADO CORRECTAMENTE LOS AJUSTES "); break; case 4: JOptionPane.showMessageDia

Pテ。gina 4


log(null ,ops.gethora()+":"+ops.getminuto s());

JOptionPane.showInputDialog(null , "INGRESA OTRO NUMERO "))); case 3: ops.suma();

JOptionPane.showConfirmDia log(null, ops.gethora()+"/ "+ops.getminutos()+"/"+ops.getan io()); break; case 5: int SUL; do{ SUL= Integer.parseInt(JOptionPane.sho wInputDialog(null, "SELECCIONA LA OPERACION QUE DESEAS REALIZAR\n 1: SUMA\n 2:RESTA\n 3:MULTIPLICACION \n 4:DIVISION \n 5:RAIZ CUADRADA \n 6: POTENCIA\n 7:FACTORIAL\n 8: APAGAR CALCULADORA ")); switch (SUL){

JOptionPane.showMessageDia log(null, ops.getsum ()); ops.seta(Integer.parseInt( JOptionPane.showInputDialog(null , "INGRESA UN NUEMRO ")));

break;

case 2:

ops.setb(Integer.parseInt( JOptionPane.showInputDialog(null , "INGRESA OTRO NUMERO "))); ops.multi();

ops.seta(Integer.parseInt( JOptionPane.showInputDialog(null , "INGRESA UN NUMERO ")));

JOptionPane.showMessageDia log(null, ops.getmul ()); ops.setb(Integer.parseInt( JOptionPane.showInputDialog(null ,"INGRESA OTRO NUMERO "))); ops.resta();

case 1: ops.getres(); ops.seta(Integer.parseInt( JOptionPane.showInputDialog(null , "INGRESA UN NUMERO ")));

ops.getmul();

JOptionPane.showMessageDia log(null, ops.getres ()); break;

break; case 4: ops.seta(Integer.parseInt( JOptionPane.showInputDialog(null , "INGRESA UN NUMERO "))); ops.setb(Integer.parseInt( JOptionPane.showInputDialog(null , "INGRESA OTRO NUMERO "))); ops.div();

ops.setb(Integer.parseInt( ops.getdiv();

HECTOR CAMPOS ALONSO

Pรกgina 5


JOptionPane.showMessageDia log(null, ops.getdiv ());

JOptionPane.showInputDialog("ING RESA UN NUMERO")));

case 8:

ops.setpotencia();

break;

ops.potencia();

default:

break; case 5: ops.seta(Integer.parseInt( JOptionPane.showInputDialog("ING RESA UN NUMERO"))); ops.setraiz(); ops.raiz();

JOptionPane.showMessageDia log(null, "EL RESULTADO ES"+ops.potencia()); case 7:

JOptionPane.showMessageDia log(null, "OPCION NO VALIDA VUELVA A INTENTAR CON OTRO NUMERO ");

double factorial=1; SUL=(Integer.parseInt(JOpt ionPane.showInputDialog(null,"IN GRESA EL NUMERO DELQUE DESEES EL FACTORIAL ")));

} }while (SUL != 8);

while ( h!=0) { JOptionPane.showMessageDia log(null,"LA RAIZ ES:"+ops.raiz());

} }while (a!=6); } }while (h!=5);

factorial=factorial*h; h--;

} }

break; case 6: } ops.seta(Integer.parseInt( JOptionPane.showInputDialog("ING RESA UN NUMERO")));

ops.seta(Integer.parseInt(

HECTOR CAMPOS ALONSO

JOptionPane.showMessageDia log(null,"el factorial es: "+factorial); break;

Pรกgina 6


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.