Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class Modulo {
- public static int validarNumero(Scanner valorIngresado, String mensaje) {
- int numero;
- String linea;
- while (true) {
- try {
- System.out.println(mensaje);
- linea = valorIngresado.nextLine();
- numero = Integer.parseInt(linea);
- break;
- } catch (Exception e) {
- System.out.println("''ERROR..! Ingrese un Numero Positivo''");
- }
- }
- return numero;
- }
- public static int elegirOpcion(Scanner opcion , String mensaje){
- int numero;
- String linea;
- while (true) {
- try {
- System.out.println(mensaje);
- linea = opcion.nextLine();
- numero = Integer.parseInt(linea);
- while(!(numero<=2 && numero>=1)){
- System.out.println("Opcion Incorrecta");
- System.out.println(mensaje);
- linea = opcion.nextLine();
- numero = Integer.parseInt(linea);
- }
- break;
- } catch (Exception e) {
- System.out.println("''ERROR..! Ingrese un numero''");
- }
- }
- return numero;
- }
- public static void cargarMatriz(int [][] x,Scanner entrada){
- for (int i=0; i<3;i++){
- for (int j=0;j<3;j++){
- System.out.println("ingrese valores de matriz");
- x[i][j]= Integer.parseInt(entrada.next());
- }
- }
- }
- public static void mostrarMatriz(int[][]x){
- for (int i=0; i<x.length;i++){
- for (int j=0;j<x.length;j++){
- System.out.print(x[i][j]+" ");
- }
- System.out.println("");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment