Mostar articulo sustantivo y verbo


MOSTRAR  UNA ORACION DONDE SE CONCATENE UN ARTICULO SU RESPECTIVO SUSTANTIVO Y UN VERBO TODO ALEATOREAMENTE


import java.util.Random;
public class Ejemplo6
{
    public static void main(String[]args){
        String articulo[] = {"EL ","UN ","LA ","UNA "};
        String sustantivo_femenino[]={" ABUELA "," TRAIDORA "," PANTERA "," SILLA "," FLOR "," MUNECA "};
        String sustantivo_masculino[]={" PADRE "," ABUELO "," LEON "," JARRON "," PATIO "," MUNECO "};
        String verbo[]={"AMENAZA","RIE","CORRE","PERDONA","JUEGA","CANTA","SALPICA","GIRA","CORRE","MIRA" };
   

        int randomVerbo;
       for(int i=0; i<10;i++){//REPITE LA AACION 10 VECES
            int randomArticulo = (int)(Math.random()*articulo.length);//GENERA UN NUMERO RANDON DEL 0 AL LARGO DEL ARREGLO ARTICULO
            if(randomArticulo < 2){//SI EL ARTICULO ES MASCULINO
                int randomSusMasculino = (int)(Math.random()*sustantivo_masculino.length);//GENERA UN NUMERO RANDON DEL 0 AL LARGO DEL ARREGLO SUSTANTIVO_MASCULINO
                randomVerbo = (int)(Math.random()*verbo.length);//GENERA UN NUMERO RANDON DEL 0 AL LARGO DEL ARREGLO VERBO
                //IMPRIME ARTICULO MASCULINO + SUSTANTIVO MASCULINO + UN VERBO TODO ELEJIGO ALEATOREAMENTE
                System.out.println(articulo[randomArticulo]+sustantivo_masculino[randomSusMasculino]+verbo[randomVerbo]);
            }else{//DE LO CONTRARIO SI ES UN ARTICULO FEMENINO
                int randomSusFemenino = (int)(Math.random()*sustantivo_femenino.length);//GENERA UN NUMERO RANDON DEL 0 AL LARGO DEL ARREGLO SUSTANTIVO FEMENINO
                randomVerbo = (int)(Math.random()*verbo.length);//GENERA NUMERO RANDON ENTRE 0 Y LARGO DEL ARREGLO VERBO
                //IMPRIME ARTICULO FEMENINO + SUSTANTIVO FEMENINO + UN VERBO TODO ELEJIGO ALEATOREAMENTE
                System.out.println(articulo[randomArticulo]+sustantivo_femenino[randomSusFemenino]+verbo[randomVerbo]);
            }
        }
    }
}

Comentarios

Entradas más populares de este blog

Juego del gato

Convertir decimal a binario, octal y hexadecima