+ 1
What am I doing wrong?
I'm a beginner trying to do a coding challenge but I keep getting errors, am I not allowed to instantiate those variables in the Program class? the intention is to convert numbers into a different base system (ie non 10-base) https://code.sololearn.com/c4G57YHUyJAs/?ref=app
6 ответов
+ 3
https://code.sololearn.com/ccesdK3rwcY7/?ref=app Check this. Is output what you expected?
+ 1
You can declare numIn and baseIn variables outside Execute method. They are just not needed as method will recognize them from parameters.
(int numIn, int baseIn). And about output...I am not sure.. Error says that it is about static keyword. When I deleted static keyword, I created object and called method with object, it worked. So here is version in which I was able to declare output variable outside Execute method without errors. Hope it helps :p
https://code.sololearn.com/cL7ufCFceWyY/?ref=app
0
Yes, thank you Tom!! So simple. But now I'm curious, why can't I place them in there to start as part of the program class? (despite the fact it would be redundant in this example)
0
Are you talking about numIn, basIn and output variables?
0
yes
0
Well looks like my theory of a simple base 10 converter is a liiitle more complicated than I thought (since it would have to be divided everytime it hits the "cap" of the base for EACH digit/figure). it works fine for the first example, but not the others. but thanks for helping me realize my folly much sooner!