Advertisement
CrazyDave23

Clase 1 - Semestre 2

Aug 7th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.48 KB | None | 0 0
  1. package tablaescuelas;
  2.  
  3.  
  4.  
  5. public class TablaEscuelas {
  6. //5000 lĂ­mite
  7.  
  8.     public static void main(String[] args) {
  9.        
  10.         //Entrada
  11.             //Generar una matriz con los datos
  12.  
  13.             String recinto = "";
  14.             char candidato = 'A';
  15.             int suma_total = 0;
  16.            
  17.             int filas = 15;
  18.             int columnas = 4;
  19.            
  20.             int matriz[][] = new int [5][15];
  21.            
  22.             generarTabla(matriz, filas, columnas);
  23.            
  24.             mostrarTabla(matriz, recinto, candidato, filas, columnas);
  25.            
  26.            
  27.     }
  28.    
  29.     public static void generarTabla(int matriz[][], int filas, int columnas){
  30.        
  31.         for (int i = 0; i<columnas ; i++){
  32.             for (int j = 0; j<filas; j++){
  33.  
  34.                 matriz[i][j] = (int) (Math.random() * 5000)+1;
  35.                    
  36.             }
  37.         }
  38.     }
  39.    
  40.     public static void mostrarTabla(int matriz[][], String recinto, char candidato, int filas, int columnas){
  41.  
  42.        
  43.         for (int i = 0; i<columnas ; i++){
  44.            
  45.             for (int j = 0; j<filas; j++){
  46.                
  47.                
  48.                 switch(i){
  49.                     case 0:
  50.                         candidato = 'A';
  51.                         break;
  52.                     case 1:
  53.                         candidato = 'B';
  54.                         break;
  55.                     case 2:
  56.                         candidato = 'C';
  57.                         break;
  58.                     case 3:
  59.                         candidato = 'D';
  60.                         break;
  61.                 }
  62.                
  63.                
  64.                 switch(j){
  65.                     case 0:
  66.                         recinto = "ESCUELA STANDARD D-534 MATTA 0151";
  67.                         break;
  68.                     case 1:
  69.                         recinto = "LICEO B-20 ANIBAL PINTO PINTO 0150";
  70.                         break;
  71.                     case 2:
  72.                         recinto = "ESCUELA D-470 ARTURO PRAT GRAL MACKENNA 685";
  73.                         break;
  74.                     case 3:
  75.                         recinto = "ESCUELA D-499 SAN ANTONIO A VARAS ESQ MATTA";
  76.                         break;
  77.                     case 4:
  78.                         recinto = "LICEO A-23 MARCELA PAZ ANTONIO VARAS 630";
  79.                         break;
  80.                     case 5:
  81.                         recinto = "HOGAR ESTUDIANTIL PRAT ESQ BILBAO";
  82.                         break;
  83.                     case 6:
  84.                         recinto = "INSTITUTO CLARET ZENTENO 453";
  85.                         break;
  86.                     case 7:
  87.                         recinto = "LICEO A-28 P. NERUDA BALMACEDA 650";
  88.                         break;
  89.                     case 8:
  90.                         recinto = "LICEO A-21 BALMACEDA 598";
  91.                         break;
  92.                     case 9:
  93.                         recinto = "ESCUELA MILLARAY RAYEN 01010";
  94.                         break;
  95.                     case 10:
  96.                         recinto = "ESCUELA LLAIMA COQUIMBO 745";
  97.                         break;
  98.                     case 11:
  99.                         recinto = "ESCUELA D-508 GABRIELA MISTRAL SN";
  100.                         break;
  101.                     case 12:
  102.                         recinto = "ESCUELA SAN FRANCISCO MONTT 071";
  103.                         break;
  104.                     case 13:
  105.                         recinto = "ESCUELA D-478 CAUPOLICAN 105";
  106.                         break;
  107.                     case 14:
  108.                         recinto = "ESC STA CAROLINA DE PEDRO DE V P DE VALDIVIA";
  109.                         break;
  110.                 }
  111.                
  112.                 System.out.println("Candidato: "+candidato+" Recinto: "+recinto + " Cant. Votos: "+matriz[i][j]);
  113.                    
  114.             }
  115.         }
  116.        
  117.     }
  118.    
  119.     public static void calcularTotal(int matriz[][], int suma_total, int filas, int columnas){
  120.        
  121.        
  122.         for (int i = 0; i<columnas ; i++){
  123.            
  124.             suma_total = 0;
  125.            
  126.             for (int j = 0; j<filas; j++){
  127.  
  128.                 suma_total += matriz[i][j];
  129.                
  130.             }
  131.  
  132.         }
  133.     }
  134.    
  135.     public static void mostrarMasVotado(int matriz[][], int suma_total, int filas, int columnas){
  136.        
  137.         for (int i = 0; i<columnas ; i++){
  138.            
  139.             for (int j = 0; j<filas; j++){
  140.  
  141.                
  142.             }
  143.         }  
  144.     }
  145. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement