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:
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:
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started