Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Alejandro Millan PE-12-1310
- Diego Rodriguez 8-863-2004 */
- import java.io.*;
- class proyecto1 {
- public static void main (String args[]) throws IOException{
- metodos obj = new metodos();
- BufferedReader br;
- br = new BufferedReader(new InputStreamReader(System.in));
- int num,valfinal,valinicial,r,vf;
- do{
- System.out.println ("\n\n\t\t\tProyecto #1");
- System.out.println ("\n\n1) Pagina de presentacion");
- System.out.println ("2) Calcular n veces R con su factorial\n\t Ejem:S = + 1/(R)!+2/(R-1)!+3/(R-2)!");
- System.out.println ("3) Resolver la formula cuadratica x² + 15x - 8 con valores una suceción");
- System.out.println ("4) Salir");
- System.out.print ("Escoja una opcion: ");
- num = Integer.parseInt(br.readLine());
- switch (num){
- case 1: obj.presentacion();break;
- case 2: System.out.print("\nIntroduzca un valor para R: ");
- r = Integer.parseInt(br.readLine());
- obj.prog2(r); break;
- case 3: System.out.println ("\t\t\tResolver la formula cuadratica\n");
- System.out.println ("X^2 + 15X - 8");
- System.out.print ("Introduzca el valor inicial de X: ");
- vf=Integer.parseInt(br.readLine());
- System.out.print("Introduzca el valor final de X: ");
- valfinal=Integer.parseInt(br.readLine());
- for (valinicial=vf;valinicial<=valfinal;valinicial++){
- obj.valor1=valinicial;
- obj.prog1(obj);
- };break;
- default: System.out.println ("\n\nUsted acaba de salir del programa... Adios");break;
- }
- }
- while (num != 4);
- }
- }
- class metodos{
- int valor1,valoresdesucecion;
- void presentacion () {
- System.out.println ("\n\t\t\tProyecto #1");
- System.out.println ("\nCreado por:");
- System.out.println ("\tAlejandro Millan PE-12-1310");
- System.out.println ("\tDiego Rodriguez 8-863-2004\n\n");
- }
- void prog1 (metodos Datos){
- int x,z;
- z= Datos.valor1*Datos.valor1+15*Datos.valor1-8;
- System.out.println ("La respuesta con el valor X de "+Datos.valor1+" es: " +z );}
- void prog2(int r){
- int i1=1,i2=0;
- String val;
- float t,fact,contador=0;
- t = (r-i2);
- while (t!=1){
- t = r-i2;
- fact = factorial(t);
- contador = contador + i1/fact;
- val = "+"+i1+"/"+"("+r+"-"+i2+")!";
- System.out.print(val);
- i1++;
- i2++;
- }
- System.out.println(" = "+contador +"\n\n");
- }
- int factorial(float z){
- int i,contador=1;
- for (i=1;i<=z;i++){
- contador = contador*i;}
- return contador;}
- }
Add Comment
Please, Sign In to add comment