Describing numbers

  • 8
  • Locked
Suppose we need to separate numbers according to some criteria. For example, based on whether they are even or odd, or based on the number of digits. Have you got a picture of that in your mind? And now for the work: we'll write a program that describes the number entered by the user (it must be in the range from 1 to 999). The description will indicate whether the number is even or odd, and how many digits it has.
You can't complete this task, because you're not signed in.
Comments (12)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Amo programmare
Level 31 , Italy
10 August 2022, 13:03
Did anyone notice that in the solution code that there is an error? Any odd negative number returns "odd one-digit number". Don't know if the developers of the website want to fix it...
Level 41
18 August 2022, 07:50
Thanks, we'll fix it asap.
Level 6 , Saskatoon, Canada
6 July 2021, 17:12
I checked for even or odd. Then I checked for string length. It didn't like that. I then adjusted my check to reflect the actual value instead of the string length. It still didn't like it. I keep getting 'Recommendation from your mentor: Be sure that the program correctly handles numbers in the specified range." Who is this mentor, and how can I have a word with him/her about their cruddy testing criteria?
Level 41
12 July 2021, 05:18
Give me your solution in PM and I'll check it.
Level 6 , Saskatoon, Canada
4 August 2021, 18:30
Wow, it has been a while - I was away on vacation. I realized that one of my errors was that I was saying 'single digit number' and then 'DOUBLE digit number' when I should have been saying 'TWO digit number', so my output strings were wrong. I was barking up the wrong tree.
Level 17 , United States
15 June 2021, 18:58
think like a coder. what is a single digit number? all numbers between 1 and 9 inclusive. Similar with two and three digit numbers, then combine it with condition if number is odd or even, and don't forget that only valid range is between 1 and 999 (any number that is less or more to result in an empty block of code, aka do nothing). Worked like a charm. For me it was helpful to watch Think Like a Coder: Best of luck everyone!
Level 15 , United Kingdom
19 August 2020, 21:49
Any idea why it didn't like my
check instead of checking whether the integer is between 1-999? I tested multiple (even negative) numbers with the length() solution and it was working fine.
Lucas Hoage
Level 14 , Savannah, United States
25 May 2020, 23:43
This was far easier than the positive and negative numbers exercise.
Mike McKenna
Level 25 , Wilmington, United States
17 August 2019, 18:14
can't cause task to verify ? I have used from 0 to 1000 . task fails last requirement . help ? Thanks
Muhammad Vahhaaj
Level 19 , Rawalpindi, Pakistan
7 June 2019, 17:08
Man what a verification technology. :O
Level 5 , Chennai, India
8 January 2019, 04:52
/* The comment was deleted */
Level 41
8 January 2019, 06:41
Posting the solution in the comments is prohibited.