Write a program that continuously prompts the user to enter integers from the keyboard. The program terminates when the integer entered is –5 or 0 or is greater than 8. Use logical ‘and’ in your loop control condition. Test your program carefully to ensure that all the loop termination criteria are met.
import java.util.Scanner;
public class ques {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input = new Scanner (System.in);
int num;
System.out.print("Enter n (-5 or 0 to stop):");
do {
num = input.nextInt();
if ((num!=-5) && (num!=0) && (num>8)){
System.out.println("Integers: "+num);
}
}while ((num!=-5) && (num!=0) && (num>8)); {
System.out.println("Integers:" +num);
}
}
}
Started out with this but couldn't complete it. Help.