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.
Describing numbers
- 8
Locked
Comments (12)
- Popular
- New
- Old
You must be signed in to leave a comment
Amo programmareExpert
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...
0
Roman
18 August 2022, 07:50
Thanks, we'll fix it asap.
0
Dave
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?
0
Roman
12 July 2021, 05:18
Give me your solution in PM and I'll check it.
0
Dave
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.
+1
NB
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: https://www.youtube.com/watch?v=qhAAmyGnA-M&list=PLJicmE8fK0EgogMqDYMgcADT1j5b911or Best of luck everyone!
0
George
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. 0
Lucas Hoage
25 May 2020, 23:43
This was far easier than the positive and negative numbers exercise.
0
Mike McKenna
17 August 2019, 18:14
can't cause task to verify ?
I have used from 0 to 1000 . task fails last requirement .
help ?
Thanks
0
Muhammad Vahhaaj
7 June 2019, 17:08
Man what a verification technology. :O
+2
Rathika
8 January 2019, 04:52
/* The comment was deleted */
0
Roman
8 January 2019, 06:41
Posting the solution in the comments is prohibited.
+1