Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

[SWIFT] 1. Create a Swift playground o Specifytheplaygroundnameas: W01_lastName_firstName where lastName is the part of your name that OSU considers to be your last name,

[SWIFT]

1. Create a Swift playground o Specifytheplaygroundnameas:

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

2. Define a class named Cash. The class contains the following public elements: o ADoublestoredpropertythatcontainstheamountofmoney(dollarsandcents)

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

number of U.S. bills and coins that add up to the amount in the stored property. The return value is an Int array of length 9 that contains (beginning with index 0 of the array) the number of $50 bills, $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 return value is:

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

o AninitializerwithoneDoubleparameter;itassignstheparametricvaluetothe stored property.

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

o Define 6 variables 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.

o Print the values of the variables to the debug area.

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

Step: 3

blur-text-image

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

Advances In Databases And Information Systems 22nd European Conference Adbis 2018 Budapest Hungary September 2 5 2018 Proceedings Lncs 11019

Authors: Andras Benczur ,Bernhard Thalheim ,Tomas Horvath

1st Edition

3319983970, 978-3319983974

More Books

Students also viewed these Databases questions