domingo, 24 de noviembre de 2013

Matrices

Este pequeño ejemplo de matrices consiste en programa que pide nombre, matricula y calificacion de 10 alumnos y al final los imprime.

Clase matrices

import java.util.Random;
import java.util.Scanner;
import java.util.Vector;

public class matrices {


private static Vector<registro> Datos;
static String n;
static Double ma;
static Double c;
public static void main (String  args []) {
Datos = new Vector<registro>();
registro  temp;
Scanner sc = new Scanner (System.in);

for (int j = 0; j < 10; j++){

System.out.println("Introduzca la matricula: ");
ma = sc.nextDouble();
System.out.println("Introduzca el nombre: ");
n = sc.next();
System.out.println("Introduzca la calificacion: ");
c = sc.nextDouble();
temp = new registro();
//ma = (Double)(Math.random() * 100000);
temp.setMatri(ma);
temp.setCal(c);
temp.setNom("Nombre " + n);
//System.out.println(temp);
Datos.addElement(temp);
}
for (int i1 = 0; i1 < Datos.size(); i1++) {

System.out.println(Datos.elementAt(i1).toString());

}
}



}
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

clase registro

public class registro {

private Double matri;
private String nom;
private double cal;
public Double getMatri() {
return matri;
}
public void setMatri(Double ma) {
this.matri = (double) ma;
}
public String getNom() {
return nom;
}
public void setNom(String nom) {
this.nom = nom;
}
public double getCal() {
return cal;
}
public void setCal(double cal) {
this.cal = cal;
}
public String toString () {
return( String.valueOf( this.matri )+ " " + this.nom + " " + this.cal);
}
}

1 comentario:

  1. Is Emperor Casino Safe? | Legalbet
    Emperor Casino is a casino that is licensed by the Kahnawake 제왕카지노 Gaming Commission under the matchpoint Kahnawake Gaming Act, which is a means of establishing a trustworthy gaming 1xbet

    ResponderEliminar