Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Practico1;
- import Practico1.Helper;
- import java.util.Scanner;
- import java.util.Random;
- public class Ejercicio3 {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- menu();
- }
- @SuppressWarnings("static-access")
- public static void menu() {
- Helper op = new Helper();
- int opcion;
- Character seguir;
- do {
- int M = op.getPositiveInt("Ingrese numero de Filas");
- int N = op.getPositiveInt("Ingrese numero de Columnas");
- int[][] matriz = new int[M][N];
- int[][] matrizT = new int[matriz[0].length][matriz.length];
- System.out.println("1 - Ingresar valores");
- System.out.println("2 - Generar valores aleatorios ");
- opcion = op.getInteger("Ingrese una opcion");
- switch (opcion) {
- case 1:
- matriz = cargarNum(matriz, N, M);
- op.mostrarArrayDosDimensiones("La matriz Cargada es", matriz, "");
- matrizT = transpuesta(matriz, matrizT, M, N);
- op.mostrarArrayDosDimensiones("Su transpuesta es", matrizT, "");
- break;
- case 2:
- matriz = generarNum(matriz,M,N);
- op.mostrarArrayDosDimensiones("La matriz generada", matriz, "");
- matrizT = transpuesta(matriz, matrizT, M, N);
- op.mostrarArrayDosDimensiones("Su transpuesta es", matrizT, "");
- menu2(matriz,matrizT);
- break;
- default:
- System.out.println("Opcion No Valida ");
- }
- System.out.println();
- seguir = op.getCharacter("Desea ingresar parametros para otra Matriz??(s/n)");
- }while(!seguir.equals('n'));
- System.out.println("Gracias :D");
- }
- @SuppressWarnings("static-access")
- public static void menu2(int[][]matriz, int[][] matrizT) {
- Helper op = new Helper();
- int opcion;
- do {
- System.out.println("Trabajar con:");
- System.out.println("1 - Matriz Original");
- System.out.println("2 - Matriz Transpuesta");
- System.out.println("3 - Cargar otra matriz");
- opcion = op.getInteger("Ingrese una opcion");
- switch(opcion) {
- case 1:
- menu3(matriz, matrizT);
- break;
- case 2:
- menu3(matriz, matrizT);
- break;
- default:
- System.out.println("teta");
- }
- }while(!(opcion==3));
- }
- @SuppressWarnings("static-access")
- public static void menu3(int[][] matriz, int[][] matrizT) {
- Helper op = new Helper();
- int opcion;
- do {
- System.out.println("Trabajar con:");
- System.out.println("1 - Producto de una fila");
- System.out.println("2 - Suma de una columna");
- System.out.println("3 - Retornar");
- opcion = op.getInteger("Ingrese una opcion");
- switch(opcion) {
- case 1:
- System.out.println("caca");
- break;
- case 2:
- System.out.println("pipi");
- break;
- default:
- System.out.println("teta");
- }
- }while(!(opcion==3));
- }
- public static int producto() {
- int prod = 0;
- return prod;
- }
- public static int suma() {
- int sum = 0;
- return sum;
- }
- public static int[][] transpuesta(int [][] matriz, int[][] matrizT, int M, int N) {
- for ( M = 0; M < matriz.length; M++) {
- for (N = 0; N < matriz[M].length; N++) {
- matrizT[N][M] = matriz[M][N];
- }
- }return matrizT;
- }
- public static int[][] generarNum(int[][] matriz,int M, int N) {
- Random azar = new Random();
- for (int i = 0; i < M; i++) {
- for (int j = 0; j < N; j++) {
- matriz[i][j] = azar.nextInt(100);
- }
- }return matriz;
- }
- public static int[][] cargarNum(int[][] matriz,int M, int N) {
- for (int i = 0; i < M; i++) {
- for (int j = 0; j < N; j++) {
- matriz[i][j] = Helper.getInteger("ingrrese valor positivo");
- }
- }return matriz;
- }
- }
Add Comment
Please, Sign In to add comment