Hi guys, even though program seems to be working fine I'm getting errors while verifying it. It asks to make sure that program can handle numbers from given range.
What am I doing wrong? Does anyone else experiencing same issue?
package pl.codegym.task.task04.task0427;
/*
Opisywanie liczb
*/
import java.io.*;
import java.util.Scanner;
public class Solution {
public static void main(String[] args) throws Exception {
//tutaj wpisz swój kod
Scanner sc = new Scanner(System.in);
int number = sc.nextInt();
int length = String.valueOf(number).length();
if(number > 0 && number < 1000) {
if(number%2 == 0) {
if(length == 1) {
System.out.print("Parzysta liczba jednocyfrowa");
} else if(length == 2) {
System.out.print("Parzysta liczba dwucyfrowa");
} else if(length == 3) {
System.out.print("Parzysta liczba trzycyfrowa");
}
} else {
if(length == 1) {
System.out.print("Nieparzysta liczba jednocyfrowa");
} else if(length == 2) {
System.out.print("Nieparzysta liczba dwucyfrowa");
} else if(length == 3)
System.out.print("Nieparzysta liczba trzycyfrowa");
}
}
}
}