diloentutospc

Cuadrado JAVA con asteriscos

Sep 24th, 2018
8,136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.66 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class CuadradoAsterisco {
  4.    
  5.     Scanner teclado = new Scanner(System.in);
  6.    
  7.     int n;
  8.    
  9.     public void entradato() {
  10.         System.out.print("Por favor ingrese lado del cuadrado: ");
  11.         n = teclado.nextInt();
  12.     }
  13.    
  14.     public void proceso() {
  15.         if(n >= 2 && n <= 50) {
  16.             for (int i = 1; i <= n; i++) {
  17.                 for (int j = 1; j <= n; j++) {
  18.                     System.out.print(" *");
  19.                 }
  20.                 System.out.println("");
  21.             }
  22.         }else {
  23.             System.out.println("Por favor ingrese un numero entre 2 y 50");
  24.         }
  25.     }
  26.    
  27.    
  28.  
  29.     public static void main(String[] args) {
  30.         CuadradoAsterisco fc = new CuadradoAsterisco();
  31.         fc.entradato();
  32.         fc.proceso();
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment