Question: Would anyone mind writing this simple swift code? Write and test the code that meets the followingrequirements. States in the USA are abbreviated with two

Would anyone mind writing this simple swiftcode? Write and test the code that meets the followingrequirements.

States in the USA are abbreviated with two letter codes. Forexample, Missouri is MO, Pennsylvania is PA, and California isCA.

Declare a variable called states that is declared as a Swiftcollection type that has elements that have keys which are astate's abbreviation and values that are a state's name. On thedeclaration line initialize the collection with an empty instanceof the collection type.

Add Missouri (MO), Pennsylvania (PA), and California (CA) to thecollection.

Using for-in iterate through the key/value pairs of thecollection and print them in the format:
is

Obtain an array of all of the state abbreviations in thecollection and assign it to a constant called stateCodes.

Iterate through the array of state abbreviations and print eachone.

Remove Pennsylvania (PA) from the collection using subscriptsyntax and assigning a nil.

Remove Missouri (MO) from the collection using theremoveValue(forKey:) method on the collection.

Using for-in iterate through the key/value pairs of thecollection and print them in the format:
is

The output of your program should look like the following:

PA is Pennsylvania
CA is California
MO is Missouri
PA
CA
MO
CA is California

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!