You are on page 1of 8

import java.io.

*;
funciona)

Tarea Ordenar Por Nombre (Imcompleto - No

public class OrdenarNombre {


public static void main(String[] args) throws IOException {
int n = 0;
String nombre[] = new String[50];
String respaldo[] = new String[50];
char salir;
String cadena;
String nombreaux;
int conversion[] = new int[50];
int conversionaux;
char caracter;
String caracteres[] = new String[50];
InputStreamReader ent = new InputStreamReader(System.in);
BufferedReader datos = new BufferedReader (ent);
do
{
System.out.print("Ingresa Nombre: ");
nombre[n] = datos.readLine();
System.out.println("");
System.out.println("Desea Ingresar Un Nuevo Nombre (s/n): ");
cadena = datos.readLine();
salir = cadena.charAt(0);
n++;

} while(salir == 's' || salir == 'S');//fin do

for(int i = 0; i < n; i++)


{
System.out.printf("\tNombre: %s\n", nombre[i]);
respaldo[i] = nombre[i];
}

// Transform
System.out.println("");
System.out.println("\t\tTransformar a Numero: ");
for(int j = 0; j < n; j++)
{
nombreaux = nombre[j];
nombreaux = nombreaux.substring(0,1);
caracter = nombreaux.charAt(0);
conversion[j] = Character.getNumericValue(caracter);
System.out.printf("\tNombre: %d\n", conversion[j] );
}
//Order
System.out.println("");
System.out.println("\t\tOrdenar Por Numero: ");
for(int i= 0; i < n; i++)
{
for(int j = 1; j < n; j++)
{
if (conversion[i]>conversion[j])
{
conversionaux = conversion[i]; conversion[i] = conversion[j];
conversion[j] = conversionaux;
}
System.out.printf("\tNombre: %d\n", conversion[i] );
}
}
//Transform Char
System.out.println("");
System.out.println("\t\tTransformar a Caracter: ");
for(int i = 0; i < n; i++)
{
caracter = (char) conversion[i];
System.out.printf("\tNombre: %s\n", caracter );
caracteres[i] = Character.toString(caracter);
System.out.printf("\tNombre: %s\n", caracteres[i] );
}
}
}

import java.io.*;
Clase en Java Numero 2 - Matriz
import java.util.Scanner;
public class ecuaciones {
static int n;
public static void main(String[] args) throws IOException {

Scanner dato = new Scanner (System.in);


System.out.println("Programa que Calcule Sistema de Ecuaciones");
System.out.println("Introduzca la Cantidad de Variables");
n = dato.nextInt();
double
double
double
double
double

m[][] = new double[n][n];


v[] = new double[n];
det;
m2[][] = new double[n][n];
r[] = new double[n];

for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
System.out.println("Introduzca Fila " + (i+1) + " columna " +
(j+1)) ;
m[i][j]= dato.nextDouble();
}
System.out.println("Introduzca Coeficiente " + (i+1) + " =");
v[i] = dato.nextDouble();
}
imprimir(m,v);

det = deter(m);
if(det==0)
{
System.out.println("No tiene Solucion");
}

else
{
for(int k=0;k<n;k++)
{
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
m2[i][j] = m[i][j];
}
m2[i][k] = v[i];
}

imprimir(m2,v);
r[k] = deter(m2);
r[k] = r[k]/det;
}
System.out.println("");
System.out.println("Valor de X = " + r[0]);
System.out.println("Valor de Y = " + r[1]);
}//else

System.out.println("");
System.out.println("El Resultado es: ");
System.out.print(det);

}
static void imprimir(double m[][], double v[])
{
System.out.println("");
System.out.println("");

for(int i=0;i<n;i++)
{
System.out.print("|\t");
for(int j=0;j<n;j++)
{
System.out.print(m[i][j]+"\t");
}
System.out.print("|\t=\t|\t" + v[i]+"\t\n");
}
}
static double deter(double m[][])
{
double resul = 1;
resul = m[0][0] * m[1][1] - m[0][1]*m[1][0];
return resul;

import java.io.*;
Primera Clase Programa que permite Obtener
las Notas y Ordenar
public class promedio
{
/**
* @param args
*/
public static void main(String[] args) throws IOException
{
// TODO Auto-generated method stub
int CI[] = new int[50];
int n = 0;
int Nota[] = new int[50];
int acum = 0;
float prom;
int CIaux;
int Notaaux;
String nombreaux;
String nombre[] = new String[50];
char OP;
String cadena;
InputStreamReader ent = new InputStreamReader(System.in);
BufferedReader datos = new BufferedReader (ent);

System.out.println("Programa Promedio");
System.out.println("\n");
do
{

System.out.println("Introduzca el Alumno " + (n+1) + ": ");


System.out.println("Introduce la Cedula: ");

cadena = datos.readLine();
CI[n] = Integer.parseInt(cadena);
System.out.println("Introduzca Nombre: ");
nombre[n] = datos.readLine();
do
{
System.out.println("Introduzca Nota: ");
cadena = datos.readLine();
Nota[n] = Integer.parseInt(cadena);
if (Nota[n]<1 || Nota[n]>20)
System.out.println("Error");
} while(Nota[n]<1 || Nota[n]>20);
acum = acum + Nota[n];
System.out.println("Desea Ingresar otro Alumno? S/N ");
cadena = datos.readLine();
OP = cadena.charAt(0);
n++;
} while(OP == 'S' || OP == 's');
imprimir(CI,nombre,Nota,n);
System.out.println("\t\t\t\t\t\t promedio es: " + acum/n);
System.out.println("1.Ordenar\n2.Orden Nota\n3.Salir");
cadena = datos.readLine();
OP = cadena.charAt(0);
if (OP=='3')

System.exit(0);
for(int i=0; i<n-1; i++)
{
for(int j=i+1; j<n;j++)
{
if(CI[i]>CI[j] && OP=='1' || (Nota[i]>Nota[j] && OP=='2'))
{
CIaux = CI[i]; CI[i]=CI[j]; CI[j]=CIaux;
nombreaux = nombre[i]; nombre[i]=nombre[j];
nombre[j]=nombreaux;
Notaaux = Nota[i]; Nota[i]=Nota[j]; Nota[j]=CIaux;

}
}
}

}
static void imprimir(int CI[],String nombre[],int Nota[], int n){
System.out.println("Cedula \t Nombre \t\t nota");
for (int i=0; i<n; i++)
{
System.out.println(CI[i] + "\t" + nombre[i] + "\t\t" + "\t" + Nota[i]);
}
}

You might also like