Menu

Swift 1 Create Swift Playground O Specifytheplaygroundnameas W01lastnamefirstname Lastname Q43858316

[SWIFT]

1. Create a Swift playground
o Specifytheplaygroundnameas:

W01_lastName_firstName
where lastName is the part of your name that OSU considers to beyour last name, and firstName is your first name. (This is theproduct naming convention we will use for all weeklyassignments.)

2. Define a class named Cash. The class contains the followingpublic elements:
oADoublestoredpropertythatcontainstheamountofmoney(dollarsandcents)

described by an object of the class.
o A read-only, computed property. The getter calculates and returnsthe minimum

number of U.S. bills and coins that add up to the amount in thestored property. The return value is an Int array of length 9 thatcontains (beginning with index 0 of the array) the number of $50bills, $20 bills, $10 bills,
$5 bills, $1 bills, 25¢ coins, 10¢ coins, 5¢ coins, and 1¢ coins.For example, if the stored property contains 47.23, the returnvalue is:

[0, 2, 0, 1, 2, 0, 2, 0, 3]
However, if the amount in the stored property is negative, returnnil.

oAninitializerwithoneDoubleparameter;itassignstheparametricvaluetothestored property.

3. In the playground (outside of the class):

o Define 6 variables of type Cash. Initialize one to a negativenumber; initialize another to zero; initialize the remainingvariables to “random-ish” amounts in the range of 0 < amount<= 100.

o Print 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