samedi 15 octobre 2016

Java pattern outlines - i need to only print the outline of a shape

System.out.print("Choose a shape: "); String shape = input.nextLine();

    if (shape.equalsIgnoreCase("left-alligned triangle")) {

        System.out.print("Enter the size: ");    
        int size = input.nextInt();

    for (int i = 0; i < size; i++) {
    for (int j = 0; j < size; j++){

        if (j <= i)
        System.out.print("*");
    }
        System.out.println("");
    }
    }

Aucun commentaire:

Enregistrer un commentaire