Describing numbers

  • 3
  • Locked
Enter an integer from the keyboard in the range 1 - 999. Display a string description as follows: "even single-digit number" - if the number is even and has one digit, "odd single-digit number" - if the number is odd and has one digit, "even two-digit number" - if the number is even and has two digi
You can't complete this task, because you're not signed in.
Comments (4)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
BobbyGWilly
Level 6 , United States of America, United States
24 January, 01:59
Fail on the range check but i clearly have a range check.
if (num < 1 && num > 999) { }
BobbyGWilly
Level 6 , United States of America, United States
24 January, 02:08
Ended up having to nest all other if's into the range check if.
if (num>0 && num<1000) {
     if (){System.out.println("even single-digit number");}
     if (){System.out.println("odd single-digit number");}
     if (){System.out.println("even two-digit number");}
     if (){System.out.println("odd two-digit number");}
     if (){System.out.println("even three-digit number");}
     if (){System.out.println("odd three-digit number");}
}
Removed Spoilers...of course ;)
Ali_Alshehri
Level 5 , Saudi Arabia
24 April, 20:34
thanks bro
Joey M Teacher at McDonogh School
27 November 2021, 21:52
Used a bunch of if//else ifs.