where is the error?

0 votes
asked Mar 6, 2018 by anonymous
public class Main

{

public static void main(String[] args) {

{

  int x = 2;

  while (x <= 3){

  if (x % 2 == 0){

   System.out.println("    #---#");

   x++;

  }else{

      System.out.println("+   +   +   +");

   x++;

  }

}

 while (x <= 10){

     if (x % 2 == 0){

     System.out.println("   #+++#");

     x++;

     }else

         System.out.println("   +   +");

         x++;

     }

 }

}

4 Answers

0 votes
answered Mar 6, 2018 by Daniel Stuckey (420 points)
You need to add } at the end :)
commented Mar 6, 2018 by Daniel Stuckey (420 points)
You dont need :) that is smile (just in case)
0 votes
answered Mar 6, 2018 by anonymous
public class Main
{

  public static void main (String[]args)
  {

    {

      int x = 2;

      while (x <= 3)
    {

      if (x % 2 == 0)
        {

          System.out.println ("   #---#");

          x++;

        }
      else
        {

          System.out.println ("+   +   +   +");

          x++;

        }

    }

      while (x <= 10)
    {

      if (x % 2 == 0)
        {

          System.out.println ("   #+++#");

          x++;

        }
      else
            {
         
          System.out.println ("   +   +");

          x++;
          
            }

    }

    }

  }

}
commented Mar 6, 2018 by anonymous
And also the last else, needs both {}.
0 votes
answered Mar 8, 2018 by Pugazharasan C

Buddy remove one '{' after the main function.

0 votes
answered Mar 9, 2018 by anonymous
put  "}"  at the end
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...