Roke98

Ejercicio3-Tp1-UNJu

Sep 13th, 2022
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.60 KB | None | 0 0
  1. package Practico1;
  2.  
  3. import Practico1.Helper;
  4. import java.util.Scanner;
  5. import java.util.Random;
  6.  
  7. public class Ejercicio3 {
  8.  
  9.     public static void main(String[] args) {
  10.         // TODO Auto-generated method stub
  11.         menu();
  12.     }
  13.  
  14.     @SuppressWarnings("static-access")
  15.     public static void menu() {
  16.         Helper op = new Helper();
  17.         int opcion;
  18.         Character seguir;
  19.          do {  
  20.             int M = op.getPositiveInt("Ingrese numero de Filas");
  21.             int N = op.getPositiveInt("Ingrese numero de Columnas");
  22.             int[][] matriz = new int[M][N];
  23.             int[][] matrizT = new int[matriz[0].length][matriz.length];
  24.             System.out.println("1 - Ingresar valores");
  25.             System.out.println("2 - Generar valores aleatorios ");
  26.             opcion = op.getInteger("Ingrese una opcion");
  27.            
  28.            
  29.             switch (opcion) {
  30.             case 1:
  31.                
  32.                 matriz = cargarNum(matriz, N, M);
  33.                 op.mostrarArrayDosDimensiones("La matriz Cargada es", matriz, "");
  34.                
  35.                 matrizT = transpuesta(matriz, matrizT, M, N);
  36.                 op.mostrarArrayDosDimensiones("Su transpuesta es", matrizT, "");
  37.                
  38.                 break;
  39.             case 2:
  40.                
  41.                 matriz = generarNum(matriz,M,N);
  42.                 op.mostrarArrayDosDimensiones("La matriz generada", matriz, "");
  43.                
  44.                 matrizT = transpuesta(matriz, matrizT, M, N);
  45.                 op.mostrarArrayDosDimensiones("Su transpuesta es", matrizT, "");
  46.                
  47.                 menu2(matriz,matrizT);
  48.                 break;
  49.             default:
  50.                 System.out.println("Opcion No Valida ");
  51.             }
  52.            
  53.             System.out.println();
  54.             seguir = op.getCharacter("Desea ingresar parametros para otra Matriz??(s/n)");
  55.         }while(!seguir.equals('n'));
  56.         System.out.println("Gracias :D");
  57.     }
  58.    
  59.     @SuppressWarnings("static-access")
  60.     public static void menu2(int[][]matriz, int[][] matrizT) {
  61.         Helper op = new Helper();
  62.         int opcion;
  63.         do {
  64.             System.out.println("Trabajar con:");
  65.             System.out.println("1 - Matriz Original");
  66.             System.out.println("2 - Matriz Transpuesta");
  67.             System.out.println("3 - Cargar otra matriz");
  68.             opcion = op.getInteger("Ingrese una opcion");
  69.            
  70.             switch(opcion) {
  71.             case 1:
  72.                 menu3(matriz, matrizT);
  73.                 break;
  74.             case 2:
  75.                 menu3(matriz, matrizT);
  76.                 break;
  77.             default:
  78.                 System.out.println("teta");
  79.             }
  80.            
  81.         }while(!(opcion==3));
  82.     }
  83.    
  84.     @SuppressWarnings("static-access")
  85.     public static void menu3(int[][] matriz, int[][] matrizT) {
  86.         Helper op = new Helper();
  87.         int opcion;
  88.         do {
  89.             System.out.println("Trabajar con:");
  90.             System.out.println("1 - Producto de una fila");
  91.             System.out.println("2 - Suma de una columna");
  92.             System.out.println("3 - Retornar");
  93.             opcion = op.getInteger("Ingrese una opcion");
  94.            
  95.             switch(opcion) {
  96.             case 1:
  97.                 System.out.println("caca");
  98.                 break;
  99.             case 2:
  100.                 System.out.println("pipi");
  101.                 break;
  102.             default:
  103.                 System.out.println("teta");
  104.             }
  105.            
  106.         }while(!(opcion==3));
  107.     }
  108.    
  109.     public static int producto() {
  110.         int prod = 0;
  111.        
  112.         return prod;
  113.     }
  114.    
  115.     public static int suma() {
  116.         int sum = 0;
  117.        
  118.         return sum;
  119.     }
  120.    
  121.     public static int[][] transpuesta(int [][] matriz, int[][] matrizT, int M, int N) {
  122.         for ( M = 0; M < matriz.length; M++) {
  123.             for (N = 0; N < matriz[M].length; N++) {
  124.                 matrizT[N][M] = matriz[M][N];
  125.             }
  126.         }return matrizT;
  127.     }
  128.    
  129.     public static int[][] generarNum(int[][] matriz,int M, int N) {
  130.         Random azar = new Random();
  131.         for (int i = 0; i < M; i++) {
  132.             for (int j = 0; j < N; j++) {
  133.                 matriz[i][j] = azar.nextInt(100);
  134.             }
  135.         }return matriz;
  136.     }
  137.    
  138.     public static int[][] cargarNum(int[][] matriz,int M, int N) {
  139.         for (int i = 0; i < M; i++) {
  140.             for (int j = 0; j < N; j++) {
  141.                 matriz[i][j] = Helper.getInteger("ingrrese valor positivo");
  142.             }
  143.         }return matriz;
  144.     }
  145. }
Add Comment
Please, Sign In to add comment