Created
January 17, 2020 14:13
-
-
Save mamiwinsfall93/59502feacf2a90e2c7dd741f5dbd8437 to your computer and use it in GitHub Desktop.
Describing numbers
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
/* | |
Describing numbers | |
Enter an integer from the keyboard in the range 1 - 999. | |
*/ | |
import java.io.*; | |
public class Solution { | |
public static void main(String[] args) throws Exception { | |
InputStreamReader sreader = new InputStreamReader (System.in); | |
BufferedReader br = new BufferedReader (sreader); | |
int n = Integer.parseInt(br.readLine()); | |
if ( n>=1 && n<=9 && n%2==0){ | |
System.out.print("even single-digit number"); | |
}else if ( n>=1 && n<=9 && n%2!=0){ | |
System.out.print("odd single-digit number"); | |
}else if (n>=10 && n<=99 && n%2==0) { | |
System.out.print("even two-digit number"); | |
}else if (n>=10 && n<=99 && n%2!=0) { | |
System.out.print("odd two-digit number"); | |
}else if (n>=100 && n<=999 && n%2==0){ | |
System.out.print("even three-digit number"); | |
}else if (n>=100 && n<=999 && n%2!=0){ | |
System.out.print("odd three-digit number"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment