import java.util.Map; import java.util.Scanner; import java.util.TreeMap; public class BIBLIO { public static void main(String[] args) { Map treeMap = new TreeMap < Integer,String>(); treeMap .put(1, "Matematica"); treeMap .put(2, "Ingles"); treeMap .put(3, "Programacion"); treeMap .put(4, "Didactica"); treeMap .put(5, "Psicologia"); treeMap .put(6, "lenguaje"); Scanner sc = new Scanner(System.in); int a; System.out.print("Introduza el codigo del libro"); a = sc.nextInt(); treeMap.get(a); System.out.println(treeMap.get(a)); } }
package notas; import java.util.Scanner; public class cedula { public static void main(String[] args) { // TODO Auto-generated method stub Scanner miScanner = new Scanner(System.in); String mensaje; do { try { Scanner t = new Scanner(System.in); int valor = 0; int conta=0; int conta2=0; int suma;
int x; int[] arreglo = new int[10];
for(int i = 0; i <=9; i++){ System.out.println("Numero " + (i+1)); valor = t.nextInt(); arreglo[i] = valor; } for(int i: arreglo){ System.out.print(i + " \n"); } for(int j=1;j<=7;j=j+2){ conta=conta+ arreglo[j]; } System.out.println("\nSuma de pares:"+conta); for(int k=0;k<=8;k=k+2){ x=arreglo[k]*2; if(x>=9) { x=x-9; } conta2=conta2+x; } System.out.print("\nSuma de impares:"+conta2); suma=conta+conta2; int res=suma%10; int res2=10-res; if(0==arreglo[9]){
System.out.print("\nCorrecto: 0"); } else { if(res2==arreglo[9]){ System.out.print("\nCorrecto: "+res2); } else { System.out.print("\nIncorrecto"+res2); } } } catch (Exception a) { System.out.println("No acepta letras ingrese numeros"); } System.out.println("\nDesea continuar?:"); mensaje = miScanner.next(); } while(!mensaje.equals("n")); } }
package mayor; import java.util.Scanner; public class mayorq { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in);
int n1,n2; try { System.out.print("Introdusca la nota: "); n1 = sc.nextInt(); System.out.print("Introdusca la nota: "); n2 = sc.nextInt(); if(n1<0 || n2<0) { System.out.println ("solo numeros positivos"); } else { if ( n1 >n2 ) { System.out.println ("el numero mayor es: "+n1); } if ( n2>n1) {
System.out.println ("el numero mayor es: "+n2); } if ( n1==n2) { System.out.println (n1+" igual "+n2); } } } catch (Exception a) { System.out.println("No acepta letras ingrese numeros");
} } }
import java.util.Scanner; public class EJERS3 { private static Scanner n; public static void main(String[] args) { n = new Scanner(System.in); double a=0; System.out.println("Ingrese la nota requerida: "); try{ a=n.nextDouble(); }catch(Exception e ){ System.out.println("no es un valor numerico"); } if(a<0) { System.out.println ("solo numeros positivos"); } else { if(a<=20 && a>18.5) { System.out.println("sobresaliente"); }else { if (a<18.4 && a>15.5) { System.out.println("muy bueno");
}else { if (a<15.4 && a>13.5) { System.out.println("bueno"); }else if (a<13.4 && a>11.5) { System.out.println("regular"); } else{ System.out.println("insuficiente"); } } } } } }
package ejercicio2;
import java.util.Scanner; public class notas { private static Scanner cr; public static void main(String[] args) { // TODO Auto-generated method stub cr = new Scanner(System.in); double a=0;
System.out.println("Ingrese la nota: "); try{ a=cr.nextDouble(); } catch(Exception e ){ System.out.println("no es un valor numerico"); } if(a<=10 && a>8.5) { System.out.println("Domina"); }else { if (a<8.4 && a>6.5) { System.out.println("Alcanza"); }else { if (a<6.4 && a>4.5) { System.out.println("No alcanza"); }else { System.out.println("Supletorio"); } } } } }
package ejercicio2;
import java.util.Scanner;
public class notas2 { private static Scanner cr;
public static void main(String[] args) { // TODO Auto-generated method stub
cr = new Scanner(System.in); double a=0; System.out.println("Ingrese la nota requerida: "); try{ a=cr.nextDouble();
}catch(Exception e ){
System.out.println("no es un valor numerico");
} if(a<=20 && a>18.5) { System.out.println("sobresaliente"); }else { if (a<18.4 && a>15.5) { System.out.println("muy bueno"); }else { if (a<15.4 && a>13.5) {
System.out.println("bueno"); }else if (a<13.4 && a>11.5) { System.out.println("regular"); }else{ System.out.println("insuficiente"); } } } }
}
import java.util.Map; import java.util.TreeMap;
public class Treemap {
public static void main(String[] args) { // TODO Auto-generated method stub
Map treeMap = new TreeMap < Integer,String>(); // creamos la interfaz7
//clave entero y valor string // se crea el objeto treemap
//llama al constructor treemap //llave y valor (Integer, string) //Ordenar los elementos que insertamos, esto se hace de menor a mayor //Se importa elobjeto y las clases
treeMap .put(1, "Jaime"); treeMap .put(4, "Intriago"); treeMap .put(2, "Andrés"); treeMap .put(3, "Balseca"); treeMap .put(6, "Siete"); treeMap .put(5, "Programación");
System.out.println(treeMap);
}
}