Output result should display a heart shape with "*". Can anyone help please (using java)

public class heart pattern
{
public static void main(string[]args) {
for (int row=0; row<6; row++)
{
for (int col=0; col<7; col=++)
{
if ((row==0 && col%3!+0) || (row==1 && col%3==0) || (row-col==2) || (row+col==8))
{
system.out.print("*");
}
else
{
system.out.print("");
}
}
system.out.println();
}
}
}

please change the title to include the language you are using

hi, I’m using java as language

thank you! now people that know Java will more easily know that they can help you.

Happy coding!

1 Like

You have some syntax errors.

col=++ should be col++

row==0 && col%3!+0 I’m guessing should be row==0 && col % 3 != 0

public class HeartPattern {
    public static void main(String[] args) {
        for (int row = 0; row < 6; row++) {
            for (int col = 0; col < 7; col++) {
                if ((row == 0 && col % 3 != 0) || (row == 1 && col % 3 == 0)
                    || (row - col == 2) || (row + col == 8)) {
                    System.out.print("*");
                } else {
                    System.out.print(" ");
                }
            }

            System.out.println();
        }
    }
}