Even / odd by boolean variable | Use of boolean variable in Java | Funcition and boolean data type
//Written in Java By Syed Ali Haider
//Student of The Hajvery
University,Lahore, Pakistan.
//Don't remove these lines for legal
use
//For more Please contact us.
package Sir_ajmal;
import java.util.Scanner;
public class java {
public static boolean even (int n)
{
if (n%2==0)
return true;
else
return false;
}
public static void main(String[] args) {
Scanner
i = new Scanner (System.in);
System.out.println("Please enter
the number here: ");
int number=i.nextInt();
boolean func = even(number);
if (func==true)
System.out.println("the number is
even");
else
System.out.println("the number is
odd");
}
}
//Written in Java By Syed Ali Haider
//Student of The Hajvery
University,Lahore, Pakistan.
//Don't remove these lines for legal
use
//For more Please contact us.
Comments
Post a Comment