Question: please use ibm swift sandbox to test it before posting the answers. Thanks!!! wift Assignment #5-Introduction to Functions Due Date: In Two Classes. Assignment Value:

please use ibm swift sandbox to test it before posting the answers. Thanks!!!

please use ibm swift sandbox to test it before posting the answers.

wift Assignment #5-Introduction to Functions Due Date: In Two Classes. Assignment Value: 5 points Do Not Spend More Than 4 Hours On This Two Class Assignment Key Ideas: functions are the basic computing building block in Sw parameters and compute a result. Impure functions can accept othe ift. Pure functions accept information thriu r information and may have side effects Write and test the following functions: //Return the productf two Doubles func mult2 (dl: Double, d2: Double) ->Double //Return a Tuple contains the sum and the produet of two Doubles func addAndMult (dl: Double, d2: Double) -> (Double, Double) //return the sum of the elementsf a Double array func sum (data: [Double])->Double //return the average of the elements of a Double array func average (data [Double])->Double //Use the Quadratic formula to solve for x given a, b, and c. Return a tuple //With three elements. The first element is the number of solutions. //The next two elements are either one of the solutions or 0.0 if //there was no solution. func quadraticFormula (a: Double, b: Double, c: Double) ->(Int, Double, Double) Test Code: print ("mult2 \ (mult2 (3.0, d2: 4.0)) ") print ("addAndMult \(addAndMult (3.0, d2: 4.0)) ") let sampleData [3.0, 4.0, 5.0, 6.0, 7.0] print ("Sum of data is.. .\ (sum(sampleData))") print ("average of data is. ..\ (average (sampleData))") print (quadraticFormula (1, b: 5, c:6)) print (quadraticFormula(1, b: 6, c:9)) print (quadraticFormula (10, b: 5, c:6)) Test Results: mult2 12.0 addAndMult (7.0, 12.0) Sum of data is...25.0 average of data is...5.0 (0, 0.0, 0.0)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!