Talk:FiM++/@comment-77.78.117.13-20141217215227
Back to page
58pages on
this wiki
this wiki
There is mistake in function how to add: it has no return statement, so in row Did you know that the number the answer was how to add using 1 and 100?
is no value assigned to variable "the answer", because functioon how to add has no return value.
And it also has totally no sense in java equivalent.
<span class="kw1" style="font-family:monospace,monospace;line-height:1.2em;font-weight:bold;color:rgb(0,0,0);">public</span><span style="font-family:monospace,monospace;line-height:1.2em;"> </span><span class="kw1" style="font-family:monospace,monospace;line-height:1.2em;font-weight:bold;color:rgb(0,0,0);">static</span><span style="font-family:monospace,monospace;line-height:1.2em;"> </span><span class="kw4" style="font-family:monospace,monospace;line-height:1.2em;font-weight:bold;color:rgb(0,0,102);">double</span><span style="font-family:monospace,monospace;line-height:1.2em;"> howToAdd</span><span class="br0" style="font-family:monospace,monospace;line-height:1.2em;color:rgb(0,153,0);">(</span><span class="kw4" style="font-family:monospace,monospace;line-height:1.2em;font-weight:bold;color:rgb(0,0,102);">double</span><span style="font-family:monospace,monospace;line-height:1.2em;"> first, </span><span class="kw4" style="font-family:monospace,monospace;line-height:1.2em;font-weight:bold;color:rgb(0,0,102);">double</span><span style="font-family:monospace,monospace;line-height:1.2em;"> last</span><span class="br0" style="font-family:monospace,monospace;line-height:1.2em;color:rgb(0,153,0);">)</span><span style="font-family:monospace,monospace;line-height:1.2em;"> </span><span class="br0" style="font-family:monospace,monospace;line-height:1.2em;color:rgb(0,153,0);">{</span> <span class="kw4" style="font-weight:bold;color:rgb(0,0,102);">double</span> sum <span class="sy0" style="color:rgb(51,153,51);">=</span> <span class="nu0" style="color:rgb(204,102,204);">0</span><span class="sy0" style="color:rgb(51,153,51);">;</span> <span class="kw1" style="font-weight:bold;color:rgb(0,0,0);">while</span> <span class="br0" style="color:rgb(0,153,0);">(</span>first <span class="sy0" style="color:rgb(51,153,51);"><=</span> last<span class="br0" style="color:rgb(0,153,0);">)</span> <span class="br0" style="color:rgb(0,153,0);">{</span> sum <span class="sy0" style="color:rgb(51,153,51);">=</span> sum <span class="sy0" style="color:rgb(51,153,51);">+</span> first<span class="sy0" style="color:rgb(51,153,51);">;;;</span> first<span class="sy0" style="color:rgb(51,153,51);">++;</span> <span class="br0" style="color:rgb(0,153,0);">}</span> <span class="br0" style="color:rgb(0,153,0);">}</span>
it is missing return statement and three times ; is completely meaningless.