CÓDIGO DEL PROGRAMA

Clase Principal
package Laplace; import java.util.Scanner; public class Principal { public static void main(String[] args) { // TODO Auto-generated method stub int n; int b; int k; int a; String sn="n"; String funcionT=""; String resultado=""; String impresion=""; String impresionfuncion=""; char signo; char signofuncion; Scanner leer = new Scanner(System.in); System.out.println("Bienvenido a la calculadora Laplace"); System.out.println("Opciones disponibles abajo"); Secundaria objeto = new Secundaria(); do { System.out.println("1. 1"); System.out.println("2. (k)t^(n)"); System.out.println("3. (k)e^(at)"); System.out.println("4. (k)sin(bt)"); System.out.println("5. (k)cos(bt)"); System.out.println("6. (k)sinh(bt)"); System.out.println("7. (k)cosh(bt)"); System.out.println("8. Para salir."); int opcion=leer.nextInt(); switch (opcion) { case 1: System.out.println("Ingrese el valor numerico."); n=leer.nextInt(); if (n>0) { funcionT = String.valueOf(n); resultado=objeto.numeros(n); }else { System.out.println("No existe factorial de "+n); } break; case 2: System.out.println("Ingrese el valor de n."); n=leer.nextInt(); System.out.println("Ingrese el valor de k"); k=leer.nextInt(); funcionT=k+"t^("+n+")"; resultado=objeto.t_elevado_n(n, k); break; case 3: System.out.println("Ingrese el valor de a."); a=leer.nextInt(); System.out.println("Ingrese el valor de k "); k=leer.nextInt(); funcionT=k+"e^("+a+"t)"; resultado=objeto.exponencial(a, k); break; case 4: System.out.println("Ingrese el valor de b."); b=leer.nextInt(); System.out.println("Ingrese el valor de k."); k=leer.nextInt(); funcionT=k+"sin("+b+"t)"; resultado=objeto.seno(b, k); break; case 5: System.out.println("Ingrese el valor de b."); b=leer.nextInt(); System.out.println("Ingrese el valor de k."); k=leer.nextInt(); funcionT=k+"cos("+b+"t)"; resultado=objeto.coseno(b, k); break; case 6: System.out.println("Ingrese el valor de b."); b=leer.nextInt(); System.out.println("Ingrese el valor de k."); k=leer.nextInt(); funcionT=k+"sinh("+b+"t)"; resultado=objeto.senohiper(b, k); break; case 7: System.out.println("Ingrese el valor de b."); b=leer.nextInt(); System.out.println("Ingrese el valor de k."); k=leer.nextInt(); funcionT=k+"cosh("+b+"t)"; resultado=objeto.cosenohiper(b, k); break; case 8: System.out.println("Gracias por utilizar nuestro programa :)"); sn="n"; break; default: System.out.println("Recurde solo puede escojer desde la opcion 1 hasta la 8"); break; }if ((opcion>0)&&(opcion<8)) { signofuncion=funcionT.charAt(0); if (signofuncion=='-') { impresionfuncion=impresionfuncion+""+funcionT; System.out.println("La funcion f(t) es: "+impresionfuncion); }else { impresionfuncion=impresionfuncion+"+"+funcionT; System.out.println("La funcion f(t) es: "+impresionfuncion); } signo=resultado.charAt(0); if (signo=='-') { impresion=impresion+""+resultado; System.out.println("La transformada de Laplace es: "+impresion); }else { impresion=impresion+"+"+resultado; System.out.println("La transformada de Laplace es: "+impresion); } System.out.println("Quiere volver a utilizarlo el programa escriba 'Si' o si desea salir escriba 'No'."); sn=leer.next(); } }while(sn.equalsIgnoreCase("Si")); if(impresion!="") { System.out.println("La funcion f(t)= "+impresionfuncion); System.out.println("Laplace de f(t): "+impresion); } } } _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ __ _ _ _ _ _ _ _ _ Clase Secundaria package Laplace; public class Secundaria { String numeros(int n) { String transformada; String resultado; transformada="(1/s)"; resultado=n+""+transformada; return resultado; } String t_elevado_n(int n, int k){ String resultado; int acu=1; for (int i=1; i<=n; i++) { acu=acu*i; } resultado=k+"("+acu+"/"+"s^("+(n+1)+"))"; return resultado; } String exponencial(int a,int k){ String resultado; if(a>0) { resultado=k+"(1"+"/"+"(s - "+a+"))"; }else { a=a*(-1); resultado=k+"(1"+"/"+"(s + "+a+"))"; } return resultado; } String seno(int b, int k){ String resultado; resultado=k+"("+b+"/"+"(s^(2) + "+((b)*(b))+"))"; return resultado; } String coseno(int b, int k){ String resultado; resultado=k+"(s/"+"(s^(2) + "+((b)*(b))+"))"; return resultado; } String senohiper(int b, int k){ String resultado; resultado=k+"("+b+"/"+"(s^(2) - "+((b)*(b))+"))"; return resultado; } String cosenohiper(int b, int k){ String resultado; resultado=k+"(s/"+"(s^(2) - "+((b)*(b))+"))"; return resultado; } }

Comentarios