Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please help me write this code in swift language in Xcode. Please NO Java or C++ code. Exercise - Structs, Instances, and Default Values Imagine
Please help me write this code in swift language in Xcode. Please NO Java or C++ code.
Exercise - Structs, Instances, and Default Values Imagine you are creating some kind of app for monitoring location. Create a GPS struct with two variable properties, latitude and longitude, both with default values of 0.0. Create a variable instance of GPS called somePlace. It should be initialized without supplying any arguments. Print out the latitude and longitude of somePlace, which should be 0.0 for both Change somePlace's latitude to 51.514004, and the longitude to 0.125226, then print the updated values. Now imagine you are making a social app for sharing your favorite books. Create a Book struct with four variable properties: title, author, pages, and price. The default values for both title and author should be an empty string. pages should default to 0, and price should default to 0.0 Create a variable instance of Book called favoriteBook without supplying any arguments. Print out the title of favoriteBook. Does it currently reflect the title of your favorite book? Probably not. Change all four properties of favoriteBook to reflect your favorite book. Then using the properties of favoriteBook, print out facts about the book Exercise - Structs, Instances, and Default Values Imagine you are creating some kind of app for monitoring location. Create a GPS struct with two variable properties, latitude and longitude, both with default values of 0.0. Create a variable instance of GPS called somePlace. It should be initialized without supplying any arguments. Print out the latitude and longitude of somePlace, which should be 0.0 for both Change somePlace's latitude to 51.514004, and the longitude to 0.125226, then print the updated values. Now imagine you are making a social app for sharing your favorite books. Create a Book struct with four variable properties: title, author, pages, and price. The default values for both title and author should be an empty string. pages should default to 0, and price should default to 0.0 Create a variable instance of Book called favoriteBook without supplying any arguments. Print out the title of favoriteBook. Does it currently reflect the title of your favorite book? Probably not. Change all four properties of favoriteBook to reflect your favorite book. Then using the properties of favoriteBook, print out facts about the bookStep 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