Skip to content

Instantly share code, notes, and snippets.

@mamiwinsfall93
Created January 17, 2020 14:13
Show Gist options
  • Save mamiwinsfall93/59502feacf2a90e2c7dd741f5dbd8437 to your computer and use it in GitHub Desktop.
Save mamiwinsfall93/59502feacf2a90e2c7dd741f5dbd8437 to your computer and use it in GitHub Desktop.
Describing numbers
/*
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