no se ami me da cero 0 todo el tiempo
Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.
Mostrar Mensajes Menúimport java.util.Scanner;
import java.util.Vector;
public class Test2 {
private Vector<Integer> vectorA = new Vector<Integer>();
private Vector<Float> vectorP = new Vector<Float>();
private Scanner scanner = new Scanner(System.in);
public Test2() {
vectorA.addElement(19);
vectorA.addElement(23);
vectorA.addElement(33);
vectorA.addElement(18);
vectorA.addElement(17);
for(int index=0;index<5;index++){
System.out.println("Peso del Alumno Nro: "+index);
float p =scanner.nextFloat();
vectorP.addElement(p);
}
System.out.println("============================================================================");
for(int index=0;index<5;index++){
System.out.println("Alumno "+index+" Edad: "+vectorA.get(index)+" Peso: "+vectorP.get(index));
}
int pM = vectorA.get(0);
Float pN = vectorP.get(0);
int index;
int p = 0,y =0;
for(index=0;index<5;index++){
if(!(pM>vectorA.get(index))){
pM = vectorA.get(index);
p = index;
}
}
for(index=0;index<5;index++){
if(!(pN<vectorP.get(index))){
pN = vectorP.get(index);
y= index;
}
}
System.out.println("============================================================================");
System.out.println("Peso de la Persona con mas edad: "+vectorP.get(p)+" Edad: "+vectorA.get(p));
System.out.println("Edad de la persona con menor peso: "+vectorP.get(y)+" Edad: "+vectorA.get(y));
System.out.println("============================================================================");
System.out.print("Ingrese la edad de la persona a buscar: ");
int n = scanner.nextInt();
if(n>0){
if(vectorA.contains(n)){
System.out.println("===============================[DATOS]======================================\n");
for(int j=0;j<5;j++){
if(vectorA.get(j) == n){
System.out.println("Encontrado: "+vectorA.get(j)+" Peso: "+vectorP.get(j)+"\n");
break;
}
}
System.out.println("============================================================================");
}else
System.out.println("No encontrado!: "+n);
}
}
/**
* @param args
*/
public static void main(String[] args) {
new Test2();
}
}
import java.util.Random;
import java.util.Vector;
public class test {
public static final int SIZE = 100;
private Vector<Integer> vectorA = null;
private Vector<Integer> vectorB = null;
private Vector<Integer> vectorC = null;
private Random random;
public test() {
vectorA = new Vector<java.lang.Integer>();
vectorB = new Vector<java.lang.Integer>();
vectorC = new Vector<java.lang.Integer>();
random = new Random();
System.out.println("---------------[ Vector ]--------------------");
for(int index=0;index<11;index++){
vectorA.addElement(random.nextInt(SIZE));
}
System.out.println(vectorA+"\n");
int m=vectorA.get(0);;
int n=vectorA.get(0);;
int posN =0;
int posM =0;
int pN =0;
int iN =0;
for(int index=1;index<11;index++){
double b = vectorA.get(index);
double b1 = b % 2;
if (b1 == 0) {pN++;vectorB.addElement(index);
}else{ iN++;vectorC.addElement(index);
}
if(!(n<vectorA.get(index))){n = vectorA.get(index);
posN = index;
}
if(!(m>vectorA.get(index))){m = vectorA.get(index);
posM = index;
}
}
System.out.println("---------------[ Menor < ]-------------------");
System.out.print("Nro: "+n);
System.out.println(" Posición: "+posN+"\n");
System.out.println("---------------[ Mayor > ]-------------------");
System.out.print("Nro: "+m);
System.out.println(" Posición: "+posM+"\n");
System.out.println("---------------[ Promedio ]-------------------");
if((pN*100/10)>(iN*100/10))
System.out.println("Promedio Mayor los Pares: "+pN*100/10+"\n");
else
System.out.println("Promedio Mayor los Impares: "+iN*100/10+"\n");
System.out.println("---------------[ Vector A|B|C < ]-------------------\n");
System.out.println("Vector A: "+vectorA);
System.out.println("Vector B: "+vectorB);
System.out.println("Vector C: "+vectorC);
}
public static void main(String[] args) {
new test();
}
}