No, with some corrections this program will tell if a number is odd or even.
This how your program should look:
public class DoWhile{
public static void main(String[]args)
{
int num=13;
int last=100;
do
{
if(IsPrime(num))
{
System.out.println(num + " is a prime number");
}
else
{
System.out.println(num+ " is NOT a prime number");
}
num++;
}
while(num <==last);
}
}
You need to define the function
IsPrime
that will check if a number is prime or not.
If you have difficulties to understand what you program do, use the debugger, it will show you.
You should learn to use the debugger as soon as possible. Rather than guessing what your code is doing, It is time to see your code executing and ensuring that it does what you expect.
The debugger allow you to follow the execution line by line, inspect variables and you will see that there is a point where it stop doing what you expect.
Debugger - Wikipedia, the free encyclopedia[
^]
http://docs.oracle.com/javase/7/docs/technotes/tools/windows/jdb.html[
^]
https://www.jetbrains.com/idea/help/debugging-your-first-java-application.html[
^]
The debugger is here to show you what your code is doing and your task is to compare with what it should do.