Join IDNLearn.com today and start getting the answers you've been searching for. Discover prompt and accurate answers from our experts, ensuring you get the information you need quickly.
Sagot :
Answer:
For the value of 7 of num, there are actually two if statements that are true and their contained code is executed.
So your line numInfo = "lucky sevens!"; is executed for sure, but then numInfo gets overwritten with by numInfo = "a single digit.";
To fix it, you have to decide how you want the program to behave, since technically, both numInfo's are equally correct.
- if you want to execute at most one if condition, chain them together like if (...) { ... } else if(...) { ... } etc.
- if you want to return multiple numInfo's, turn it into a collection where you add strings
Thank you for joining our conversation. Don't hesitate to return anytime to find answers to your questions. Let's continue sharing knowledge and experiences! Discover insightful answers at IDNLearn.com. We appreciate your visit and look forward to assisting you again.