Answered step by step
Verified Expert Solution
Question
1 Approved Answer
use language swift and please test this in swift ibm sandbox to check it. Thanks. Write and test the following functions: /Given an array of
use language swift and please test this in swift ibm sandbox to check it. Thanks.
Write and test the following functions: /Given an array of integers, tind the tirst index in the array that matches //a given number, Return nil if there is no match funo findNumberInArray (data: (Int), numbertorind: Int)->Int? // return the sum of the squares of the elements of a Double azray funo sumsquares (data: [Double)- Double /Given a single Int digit return its english name. Return "number is not a digit" i the given //Int is not a digit funo returnDigitName (digit: Int)-string on your age. If your //A movie theater has an odd ticked pricing method. It depends /age is between 5 -10, the price is 1/2 of your age. If your age is between 30 the price is 1/3 of your age. If your age is between 31 and 60, //the price is 1/5 of your age. Else the ticket is $5 //Hint: Convert the age to a Double before doing calculations fune computesillyTicketPrice (age: Int)-> Double Test Code: let datal (12, 34, 17, 10, , 6) print (findNumberInArray (datal, numberToFind: 10) print (findNumberInArray (datal, numberToFind: 20) print (sumSquares ((3.0 4.0. 5.0)) print (returnDigitName (2) print (returnDigitName(8) print (returnDigitName (12)) print (computesillyTicketPrice(8) print (computeSillyTicketPrice (15)) print (computesillyTicketPrice (40) print (computeSillyTicketPrice (62)) Expected output: Optional (3) nil 50.0 tHO eight 12 is not a digit 4.0 Write and test the following functions: /Given an array of integers, tind the tirst index in the array that matches //a given number, Return nil if there is no match funo findNumberInArray (data: (Int), numbertorind: Int)->Int? // return the sum of the squares of the elements of a Double azray funo sumsquares (data: [Double)- Double /Given a single Int digit return its english name. Return "number is not a digit" i the given //Int is not a digit funo returnDigitName (digit: Int)-string on your age. If your //A movie theater has an odd ticked pricing method. It depends /age is between 5 -10, the price is 1/2 of your age. If your age is between 30 the price is 1/3 of your age. If your age is between 31 and 60, //the price is 1/5 of your age. Else the ticket is $5 //Hint: Convert the age to a Double before doing calculations fune computesillyTicketPrice (age: Int)-> Double Test Code: let datal (12, 34, 17, 10, , 6) print (findNumberInArray (datal, numberToFind: 10) print (findNumberInArray (datal, numberToFind: 20) print (sumSquares ((3.0 4.0. 5.0)) print (returnDigitName (2) print (returnDigitName(8) print (returnDigitName (12)) print (computesillyTicketPrice(8) print (computeSillyTicketPrice (15)) print (computesillyTicketPrice (40) print (computeSillyTicketPrice (62)) Expected output: Optional (3) nil 50.0 tHO eight 12 is not a digit 4.0Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started