Created
October 28, 2016 14:40
-
-
Save abdulateef/1cb63797068b71616797c1b9cd90c3f1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
import jdk.nashorn.internal.parser.TokenType; | |
public class ConditionStatement { | |
public static void main(String [] args){ | |
/// scanner to read input name and number | |
///though name not neccessary | |
///happy coding..... | |
Scanner input = new Scanner(System.in); | |
System.out.println("Enter your Name"); | |
String name = input.next(); | |
System.out.println("This Code was developed by:" + " " + name +";"); | |
System.out.println("Enter a Number"); | |
try | |
{ //to read input from user | |
int number = input.nextInt(); | |
//odd condition | |
if (number%2==1) { | |
System.out.println("Weird"); | |
//even and in the range of "" condition | |
}else if (number%2==0 && number <=10) { | |
System.out.println("Not Weird"); | |
//even and graeter than the range of "" condition | |
}else if (number%2==0 && number>10) { | |
System.out.println("Weird"); | |
} | |
}catch(Exception ex) | |
{ | |
//exception handler in case of wrong input | |
System.out.println("Enter a valid Number"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks