Ver Mensaje Individual
  #2 (permalink)  
Antiguo 17/05/2012, 17:33
gobodeath
 
Fecha de Ingreso: marzo-2012
Mensajes: 75
Antigüedad: 12 años, 1 mes
Puntos: 3
Respuesta: como crear la siguiente figura en java?

Código Javascript:
Ver original
  1. package triangulocuadrado;
  2. import javax.swing.JOptionPane;
  3. /**
  4.  *
  5.  * @author @velandia
  6.  */
  7. public class Triangulocuadrado {
  8.  
  9.  
  10.     public static void main(String[] args) {
  11.             int b=Integer.parseInt(JOptionPane.showInputDialog(null,"Ingrese la altura de la figura"));
  12.             int a=Integer.parseInt(JOptionPane.showInputDialog(null,"Ingrese la Base de la figura"));
  13.            
  14.                    for (int i = 1; i <= b; i++) {
  15.                    
  16.             for (int j = 1; j <= a; j++) {
  17.                 if(i==1||i==b||j==1||j==a){
  18.                     System.out.print("*");
  19.                 }else{
  20.                    int l=j;
  21.                     for(int k=l;k<=l;k++){
  22.                     if(i==k-4){
  23.                     System.out.print("*");    
  24.                     }else{
  25.                    
  26.                     System.out.print(" ");
  27.                     }
  28.                     }
  29.                 }
  30.                     }
  31.             System.out.println("");
  32.                 }
  33.  
  34.             }
  35.  
  36.       }

ESTO ES LO QUE yo he hecho pero no se como hacer la otra linea =S