I have an assignment to make a calculator to calculate the average number of given inputs.
I will need to accept and display number entered in the range between 0 and 100 (‘ADD’ button). And calculate and display the average.
There is a UITextField where i enter the numbers , then press the ADD button to display it into a label/textview (im not sure which to use).
The numbers should be appended into an array so as to use the averageOf() function.
I've tried displaying the numbers but the label replace the new number instead of adding it. Im very new to swift and not sure how to code to accept only a certain range of number.
My text field :
@IBOutlet weak var txtInput: UITextField!
ADD button :
@IBAction func btnAdd(_ sender: UIButton) {
let testScore = txtInput.text
scoreDisplay.text = testScore
}
The output/display of number should be , example , 40, 23.6, 98.2, 74.4
What i get is just the replacement of numbers.