Data update
This commit is contained in:
parent
ed705008a8
commit
0df55f9f24
2196 changed files with 32999 additions and 3075 deletions
|
|
@ -0,0 +1,12 @@
|
|||
repeat
|
||||
print "Enter integral rainfall (99999 to quit): "
|
||||
i = number input
|
||||
until i = 99999
|
||||
if error = 1 or i < 0 or i mod 1 <> 0
|
||||
print "Must be an integer no less than 0, try again."
|
||||
else
|
||||
n += 1
|
||||
sum += i
|
||||
print " The current average rainfall is " & sum / n
|
||||
.
|
||||
.
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
import Foundation
|
||||
|
||||
var mean: Double = 0
|
||||
var count: Int = 0
|
||||
var prompt = "Enter integer rainfall or 99999 to exit:"
|
||||
var term = " "
|
||||
print(prompt, terminator: term)
|
||||
while let input = readLine() {
|
||||
defer {
|
||||
print("count: \(count), mean: \(mean.formatted())\n\(prompt)", terminator: term)
|
||||
}
|
||||
guard let val = Int(input) else {
|
||||
print("Integer values only")
|
||||
continue
|
||||
}
|
||||
if val == 99999 {
|
||||
(prompt, term) = ("Done","\n")
|
||||
break
|
||||
}
|
||||
count += 1
|
||||
mean += Double(val)/Double(count) - mean/Double(count)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue