



Prepara tus exámenes y mejora tus resultados gracias a la gran cantidad de recursos disponibles en Docsity
Gana puntos ayudando a otros estudiantes o consíguelos activando un Plan Premium
Esta página no es visible en la vista previa
¡No te pierdas las partes importantes!




/* 1. Ingrese un número N y determine si es par o impar. Si el número es par entonces se debe calcular 3N -2, en caso contrario se debe calcular 2N+1. / import java.io.; public class Ejercicio1{ public static void main(String [] args)throws IOException{ BufferedReader br= new BufferedReader(new InputStreamReader(System.in)); int N, R1,R2; System.out.println("Ingresar un número: "); N=Integer.parseInt(br.readLine()); if(N!=0){ if(N%2==0){ System.out.println("El número es par"); R1=3N-2; System.out.println("Elresultado es: "+ R1); } else{ System.out.println("El número es impar"); R2=2N+1; System.out.println("Elresultado es: "+ R2); } } else{ System.out.println("Ud. ingreso un CERO.."); }
/Determinar si un alumno aprueba a reprueba un curso, sabiendo que aprobara si su promedio de tres calificaciones es mayor o igual a 11; reprueba en caso contrario./ import java.io.*; public class Ejercicio2{ public static void main(String [] args)throws IOException{ BufferedReader br= new BufferedReader(new InputStreamReader(System.in)); double N1, N2, N3, PROM; System.out.println("Ingresar nota 1: "); N1=Double.parseDouble(br.readLine()); System.out.println("Ingresar nota 2: "); N2=Double.parseDouble(br.readLine()); System.out.println("Ingresar nota 3: "); N3=Double.parseDouble(br.readLine()); if (N1>=0 && N1<=20 && N2>=0 && N2<=20 && N3>=0 && N3<=20){ PROM=(N1+N2+N3)/3; if(PROM>=11){ System.out.println("El promedio es: "+PROM); System.out.println("APROBADO"); } else{ System.out.println("El promedio es: "+PROM); System.out.println("DESAPROBADO"); } } else{ System.out.println("Dato incorrecto..."); } } }
/* 4. Ingrese tres números diferentes y luego imprímalos de tal modo que siempre estén en orden descendente. / import java.io.; public class Ejercicio4{ public static void main(String [] args)throws IOException{ BufferedReader br= new BufferedReader(new InputStreamReader(System.in)); int N1, N2, N3; System.out.println("Ingresar número 1: "); N1=Integer.parseInt(br.readLine()); System.out.println("Ingresar número 2: "); N2=Integer.parseInt(br.readLine()); System.out.println("Ingresar número 3: "); N3=Integer.parseInt(br.readLine()); if (N1!=N2 && N2!=N3 && N1!= N3) { if (N1< N2 && N2 < N3) { System.out.println( N3+" < " +N2+"<"+ N1); } else { if (N1<N3 && N3<N2) { System.out.println( N2+"\t"+ N3+"\t"+ N1); } else { if (N2<N1 && N1<N3) { System.out.println(N3+"\t"+N1+"\t"+ N2); } else { if (N2 < N3 && N3 <N1) { System.out.println(N1+"\t"+ N3+"\t"+ N2); } else { if (N1<N3 && N3<N2) if (N1!=N2 && N2!=N3 && N1!= N3) { if (N1< N2 && N2 < N3) { System.out.println( N3+" < " +N2+"<"+ N1); } else { if (N1<N3 && N3<N2) { System.out.println( N2+"\t"+ N3+"\t"+ N1); } else { if (N2<N1 && N1<N3) { System.out.println(N3+"\t"+N1+"\t"+ N2); } else { if (N2 < N3 && N3 <N1) { System.out.println(N1+"\t"+ N3+"\t"+ N2); } else { if (N3 < N1 && N1<N2) { System.out.println(N2+"\t"+ N1+"\t"+ N3); } else { System.out.println(N1+"\t"+ N2+"\t"+ N3); } } } } } } else{ System.out.println("Datos incorrectos..."); }