Soloway's recurring rainfall: Difference between revisions

added RPL
(added RPL)
Line 1,111:
Integer units of rainfall in this time period? (999999 to finalize and exit)>: 999999
Average rainfall 0.00 units over 0 time periods.</pre>
 
=={{header|RPL}}==
{{works with|HP|28}}
{| class="wikitable" ≪
! RPL code
! Comment
|-
|
≪ "Enter rainfall, then ENTER" 1 DISP
"" "0123456789"
'''DO DO UNTIL''' KEY '''END'''
'''IF''' DUP2 POS '''THEN'''
ROT OVER + DUP 2 DISP ROT ROT
'''END'''
'''UNTIL''' "ENTER" == '''END'''
DROP STR→
≫ '<span style="color:blue">READB</span>' STO
≪ "Enter 9999 to end" 4 DISP
(0,0) 1 CF CLLCD
DO READB
'''IF''' DUP 9999 == '''THEN''' 1 SF
'''ELSE'''
1 R→C +
"Average = " OVER RE LAST IM / →STR +
3 DISP
'''END'''
'''UNTIL''' 1 FS? '''END'''
SWAP DROP CLMF
'''IFERR''' RE LAST IM / '''THEN''' DROP2 '''END'''
≫ '<span style="color:blue">RFALL</span>' STO
|
<span style="color:blue">READB</span> ''( → n )''
Initialize variables
Loop
if keystroke is an accepted char
add char to output and display it
until ENTER is pressed
clean stack and convert to integer
<span style="color:blue">RFALL</span> ''( → ) ''
initialize counters and flag, clear screen
loop
get rainfall
if break value then set flag
otherwise
accumulate rainfall and increment count
display average rainfall
until flag set
clean stack, unfreeze display
put average rainfall in stack if count ≠ 0
|}
 
 
=={{header|Ruby}}==
Line 1,135 ⟶ 1,192:
puts "#{count} numbers entered, averaging #{average}"
</syntaxhighlight>
 
=={{header|Rust}}==
<syntaxhighlight lang="rust">
1,150

edits