Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Computer Performance Engineering 10th European Workshop Epew 2013 Venice Italy September 17 2013 Proceedings

Authors: Maria Simonetta Balsamo ,William Knottenbelt ,Andrea Marin

2013 Edition

3642407242, 978-3642407246

More Books

Students also viewed these Programming questions

Question

What do we mean when we say that MRP is based on dependent demand?

Answered: 1 week ago