0
package hw.loops.co.il;

import java.util.Scanner;

public class LoopsTargilMedium3 {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int num;

        do {
            System.out.println("Please enter a number:");
            num = input.nextInt();

            if (num%2==0) {
                System.out.println("The number " + num + " is ZUGI");
            }   
            else {
                System.out.println("The number " + num + " is E-ZUGI");

                num++;
            } while (num!=-1);
            System.out.println("loop stoped");
        }
    }
}

Receiving this error:

Exception in thread "main" java.lang.Error:
Unresolved compilation problem:
    Syntax error, insert "while ( Expression ) ;" to complete DoStatement 
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433

3 Answers3

1

you have misplaced a closing bracket before while:

..
      } //<-- missing this
    }while (num!=-1);
                System.out.println("loop stoped");
...
apomene
  • 14,282
  • 9
  • 46
  • 72
1
public class LoopsTargilMedium3 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int num;

        do {
            System.out.println("Please enter a number:");
            num = input.nextInt();

            if (num%2==0) {
                System.out.println("The number " + num + " is ZUGI");
            }   
            else {
                System.out.println("The number " + num + " is E-ZUGI");

                num++;
            } 
            System.out.println("loop stoped");
        }while (num!=-1);
    }

}
Khaled Lela
  • 7,831
  • 6
  • 45
  • 73
Dinesh
  • 1,046
  • 1
  • 8
  • 17
0
please check do while loop syntax
//--------------------------
do {
     // statements
} while (expression);

---------------------//


import java.util.Scanner;

public class LoopsTargilMedium3 {

   public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int num;
        do {
            System.out.println("Please enter a number:");
            num = input.nextInt();

            if (num%2==0) {
                System.out.println("The number " + num + " is ZUGI");
            }   
            else {
                System.out.println("The number " + num + " is E-ZUGI");

                num++;
            } 


        }

        while (num!=-1);
 System.out.println("loop stoped");



    }
}
Vishal Sharma
  • 1,051
  • 2
  • 8
  • 15