diff --git a/Array_Elecciones.java b/Array_Elecciones.java index e00e7e6..056918f 100644 --- a/Array_Elecciones.java +++ b/Array_Elecciones.java @@ -10,239 +10,83 @@ */ /* codigo ingresado*/ -correcion agregada +correcion agregada import javax.swing.*; -import java.util.Scanner; public class ArrayElecciones { - public static void main(String args[]) { -//ivan mauricio leal alvarez---------------- -Scanner teclado = new Scanner(System.in);//---creando objeto para pedir datos por teclado -// variables inicializadas - // Arreglos - // matriz inicializado con 5 candidatos - String Candidatos [] = { " Juan" , " Pedro" ,"jesus","manuel","pepito" }; + public static void main(String args[]) { + + + //ivan mauricio leal alvarez---------------- + + // Arreglos + // matriz inicializado con 5 candidatos + String Candidatos [] = { " Juan" , " Pedro" ,"Jesus","Manuel","Ismael" }; - // matriz inicializado con 6 sedes - String SedeFila [] = { " Aguazul ", "trinidad","paz deariporo","pore","tauramena" }; + // matriz inicializado con 29 sedes + String SedeFila [] = { " APARTADO ", " ARMENIA "," BOGOTÀ "," BUCARAMANGA "," BUGA "," CALI "," CARTAGO "," CAUCASIA "," CUCUTA ", + " DUITAMA "," IBAGUE "," IPIALES "," MANIZALES "," MEDELLIN ", " MONTERIA "," PALMIRA "," PASTO "," PEREIRA ", + " POPAYAN "," QUIBDO "," RIONEGRO "," SAHAGUN "," SINCELEJO "," SOGAMOSO "," TULUA "," TUMACO "," TUNJA "," VILLAVICENCO "," YOPAL "}; - // matriz que almacena los votos - int f,c; - int[][] Votos; - int []vecres; - int numerom=0; - String casilla = null; - - Votos = new int [5][6]; - vecres= new int [5]; - //------------John Fredy Bonilla----------------------- + // matriz que almacena los votos + int Votos [][]; + int veces []; + + // variables inicializadas + int SedeFil=29; + int CandiColum=5; + + + //------------John Fredy Bonilla----------------------- - // ingreso de votos - for(f=0 ; f< SedeFila.length ; f++) - { - for(c=0 ; c< Candidatos.length;c++) - { - System.out.println("Porfavor ingrese la cantidad de votos que saco en el municipio ("+SedeFila[f]+") el candidato ("+Candidatos[c]+") "); - // Votos[SedeFila][CandiColum]=teclado.nextInt();// - Votos[f][c]= teclado.nextInt(); + // ingreso de votos + Votos = new int[SedeFil][CandiColum]; + for(int f=0 ; f< SedeFila.length ; f++){ + for(int c=0 ; c< Candidatos.length;c++){ + Votos[f][c] = Integer.parseInt(JOptionPane.showInputDialog("Porfavor ingrese la cantidad de votos que saco en la sede " + +SedeFila[f]+ " el candidato " +Candidatos[c])); } } - //operacion suma por columnas - for(f=0 ; f< SedeFila.length ; f++) - { - int sumaC=0; - for(c=0 ; c< Candidatos.length;c++) - { - sumaC=Votos[c][f]+sumaC; - vecres[f]=sumaC; - - } - System.out.println("candidato "+Candidatos[f]+" resultado es: " + vecres[f]); - - } - - //contibucion carlos cogua - // comparacion de puntuacion mayor - for(f=0 ; f< SedeFila.length ; f++) - { - if(vecres[f]>vecres[f]) - { - numerom = vecres[0]; - casilla = Candidatos[f]; - - } - else - { - if(vecres[f]>numerom) - { - numerom =vecres[f]; - casilla = Candidatos[f]; - } - - } - } - System.out.println("Con una votacion de "+ numerom+ " el candidadto ganador para director de sede yopal es ; " +casilla); - - } - - -✰✰✰✰✰--ZARYS VARGAS--✰✰✰✰✰✰ - -import javax.swing.JOptionPane; -import javax.swing.JScrollPane; -import javax.swing.JTextArea; - -/** - * - * @author PORTATIL - */ -public class Votaciones { - - - public static void main(String[] args) { - - - - String candidatos[], sedes[]; - int votos[][]; - - - int fil, col; - - JTextArea area = new JTextArea(15, 30); - JScrollPane scroll = new JScrollPane(area); - - fil = Integer.parseInt(JOptionPane.showInputDialog("ingrese el numero de las sedes")); - sedes = new String[fil]; - - for (int x = 0; x < fil; x++) { - sedes[x] = JOptionPane.showInputDialog("nombre para la sede N:" + (x + 1)); - } - - - col = Integer.parseInt(JOptionPane.showInputDialog("Ingrese e numero de candidatos")); - candidatos = new String[col]; - for (int x = 0; x < col; x++) { - candidatos[x] = JOptionPane.showInputDialog("nombre del candidato n:" + (x + 1)); - } - - votos = new int[fil][col]; - - for (int x = 0; x < fil; x++) { - for (int y = 0; y < col; y++) { - votos[x][y] = Integer.parseInt(JOptionPane.showInputDialog("ingrese los votos de la sede " + sedes[x] + " paea el candidato " + candidatos[y])); - + + //operacion suma por columnas + veces = new int[Candidatos.length]; + for (int y=0; y