Search code snippets, questions, articles...

dibujar un cuadrado de nxn dimensiones

import java.util.Scanner;

public class App {

    public static void imprimir_cuadrado(int dimensiones) {

        for (int vertical = 0; vertical < dimensiones; vertical++) {
            System.out.println("");
            for (int horizontal = 0; horizontal < dimensiones; horizontal++) {
                System.out.print("* ");
            } // for horizontal

        } // for vertical

    } // metodo para imprimir el cuadrado

    public static void main(String[] args) {
        Scanner read = new Scanner(System.in);

        System.out.print("Introduce las dimensiones del cuadrado: ");
        int dimensiones = read.nextInt(); // read dimensiones

        imprimir_cuadrado(dimensiones);

    } // main

}
Was this helpful?
0 Comments