Hello!
In this exercise I’m doing, I’m supposed to convert my age into dog years, but when I run it I don’t even get the option to enter my age. My code is:
And it spits out:
Doesn’t give me a prompt to enter my age.
Does anyone know why? This exercise is on Code Academy. Thank you!
It’s because 1 human year is 7 dog years, not 15.
Seriously though, I don’t see any immediate issue with the code. You must be executing some other program? That or some other non-code issue is happening. Assuming that is the only code in your project and solution.
It is. Okay! Yeah, I looked up the years and google said 15 lol.
I have found Code Academy to have other things going on occasionally that confuse a learner like myself, so if there isn’t anything that jumps out, I’ll reluctantly move on. This is all that I have in the console so… *shrug*
How are you compiling and executing it? In what environment?
It is in Code Academy’s interface. So I guess it’s a virtual console.
Are you inputting a value because I don’t see it in your screenshot. It looks like you are just hitting enter.
I run your code on https://dotnetfiddle.net/ and it works as expected.
https://dotnetfiddle.net/IouHqw
Sorry, yeah it doesn’t even give me the option to input anything. As soon as it runs it spits all of that output at once. I’ll check out the link, ty!
This sounds like a glitch in the CodeAcademy environment. It’s possible it’s confused because you’re doing two things on one line. Try reworking the first few lines to look like this:
I switched from Convert.ToInt32()
to int.Parse()
. This is generally what more people reach for. There are some arguments about that, and some will say to go ahead and use TryParse()
, but I made this change just in case one of the quirks of Convert
is on the table. Parse()
is a little more predictable, and you need to figure out what the heck is up with CA before getting into philosophical discussions about input conversion.
I will give Parse() a shot. I wasn’t quite sure what that did yet, but I did see someone suggest that in the forums, I just have no idea.
But yes, as a brand new learner any side quirks that you wouldn’t normally deal with is ultra confusing. Ty!