Answered step by step
Verified Expert Solution
Link Copied!

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.

image text in transcribed

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.0

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

12th edition

133544613, 978-0133544619

More Books

Students also viewed these Databases questions