+ 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

24th Feb 2018, 8:19 AM
Kevin C
6 Antworten
+ 3
https://code.sololearn.com/ccesdK3rwcY7/?ref=app Check this. Is output what you expected?
24th Feb 2018, 8:31 AM
Sad
Sad - avatar
+ 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
24th Feb 2018, 9:02 AM
Sad
Sad - avatar
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)
24th Feb 2018, 8:39 AM
Kevin C
0
Are you talking about numIn, basIn and output variables?
24th Feb 2018, 8:43 AM
Sad
Sad - avatar
0
yes
24th Feb 2018, 8:45 AM
Kevin C
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!
24th Feb 2018, 9:08 AM
Kevin C