Menu

Swift 1 Create Swift Playground O Specifytheplaygroundnameas W01lastnamefirstname Lastname Q43888016

[SWIFT] 1. Create a Swift playground oSpecifytheplaygroundnameas: W01_lastName_firstName where lastNameis the part of your name that OSU considers to be your last name,and firstName is your first name. (This is the product namingconvention we will use for all weekly assignments.)

2. Define a class named Cash. The class contains the followingpublic elements: o A Double stored property that contains theamount of money (dollars and cents) described by an object of theclass. o A read-only, computed property. The getter calculates andreturns the minimum number of U.S. bills and coins that add up tothe amount in the stored property. The return value is an Int arrayof length 9 that contains (beginning with index 0 of the array) thenumber of $50 bills, $20 bills, $10 bills, $5 bills, $1 bills, 25¢coins, 10¢ coins, 5¢ coins, and 1¢ coins. For example, if thestored property contains 47.23, the return value is: [0, 2, 0, 1,2, 0, 2, 0, 3] However, if the amount in the stored property isnegative, return nil. oAninitializerwithoneDoubleparameter;itassignstheparametricvaluetothestored property.

3. In the playground (outside of the class): o Define 6variables of type Cash. Initialize one to a negative number;initialize another to zero; initialize the remaining variables to“random-ish” amounts in the range of 0 < amount <= 100. oPrint the values of the variables to the debug area.

Expert Answer


Answer to [SWIFT] 1. Create a Swift playground o Specifytheplaygroundnameas: W01_lastName_firstName where lastName is the part of …

OR