Note These exercises reinforce Swift concepts in the context of a fitness tracking app. or most apps you'll need to have a data structure to hold information about a user. Create a User struct that has properties for basic information about a user. At a ninimum, it should have properties to represent a user's name, age, height, weight, and activity level. You could do this by having name be a String, age be an Int, eight and weight be of type Double, and activityLevel be an Int that will represent a scoring 1-10 of how active they are. Implement this now. Create a variable instance of User and call it your name. Use the memberwise initializer to pass in information about yourself. Then print out a description of your User nstance using the instance's properties. n previous app exercises, you've worked with dist f measurement. Create a Distance struct that will represent distance in various units of measurement. At a minimum, it should have a meters property and a feet in tracking app example as a simple : imbe distance can be represented using a variety of uni roperty. Create a custom initializer corresponding to each property (i.e. if you only have the two properties for meters and feet you will then have two initializers) that will ake in a distance in one unit of measurement and assign the correct value to both units of measurements. Hint: 1 meter = 3.28084 feet. Example If you use the initializer for meters and pass in a distance of 1600, the initializer should set meters to 1600 and feet to 5249.344.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

How do I solve this using Swift Code? 4 of 10

 

App Exercise - Users and Distance
Note
These exercises reinforce Swift concepts in the context of a fitness tracking app.
For most apps you'll need to have a data structure to hold information about a user. Create a User struct that has properties for basic information about a user. At a
minimum, it should have properties to represent a user's name, age, height, weight, and activity level. You could do this by having name be a String, age be an Int,
height and weight be of type Double, and activityLevel be an Int that will represent a scoring 1-10 of how active they are. Implement this now.
Create a variable instance of User and call it your name. Use the memberwise initializer to pass in information about yourself. Then print out a description of your User
instance using the instance's properties.
In previous app exercises, you've worked with distance in the fitness tracking app example as a simple number. However, distance can be represented using a variety of units
of measurement. Create a Distance struct that will represent distance in various units of measurement. At a minimum, it should have a meters property and a feet
property. Create a custom initializer corresponding to each property (i.e. if you only have the two properties for meters and feet you will then have two initializers) that will
take in a distance in one unit of measurement and assign the correct value to both units of measurements. Hint: 1 meter
3.28084 feet.
Example
If you use the initializer for meters and pass in a distance of 1600, the initializer should set meters to 1600 and feet to 5249.344.
Transcribed Image Text:App Exercise - Users and Distance Note These exercises reinforce Swift concepts in the context of a fitness tracking app. For most apps you'll need to have a data structure to hold information about a user. Create a User struct that has properties for basic information about a user. At a minimum, it should have properties to represent a user's name, age, height, weight, and activity level. You could do this by having name be a String, age be an Int, height and weight be of type Double, and activityLevel be an Int that will represent a scoring 1-10 of how active they are. Implement this now. Create a variable instance of User and call it your name. Use the memberwise initializer to pass in information about yourself. Then print out a description of your User instance using the instance's properties. In previous app exercises, you've worked with distance in the fitness tracking app example as a simple number. However, distance can be represented using a variety of units of measurement. Create a Distance struct that will represent distance in various units of measurement. At a minimum, it should have a meters property and a feet property. Create a custom initializer corresponding to each property (i.e. if you only have the two properties for meters and feet you will then have two initializers) that will take in a distance in one unit of measurement and assign the correct value to both units of measurements. Hint: 1 meter 3.28084 feet. Example If you use the initializer for meters and pass in a distance of 1600, the initializer should set meters to 1600 and feet to 5249.344.
In previous app exercises, you've worked with distance in the fitness tracking app example as a simple number. However, distance can be represented using a variety of units
of measurement. Create a Distance struct that will represent distance in various units of measurement. At a minimum, it should have a meters property and a feet
property. Create a custom initializer corresponding to each property (i.e. if you only have the two properties for meters and feet you will then have two initializers) that will
take in a distance in one unit of measurement and assign the correct value to both units of measurements. Hint: 1 meter =
3.28084 feet.
Example
If you use the initializer for meters and pass in a distance of 1600, the initializer should set meters to 1600 and feet to 5249.344.
Now create an instance of Distance called mile. Use the initializer for meters to set the distance to 1600. Print out the property for feet and verify that it is equal to
5249.344.
Now create another instance of Distance and give it some other distance. Ensure that both properties are set correctly.
Previous | page 4 of 10 | Next: Exercise - Methods
Transcribed Image Text:In previous app exercises, you've worked with distance in the fitness tracking app example as a simple number. However, distance can be represented using a variety of units of measurement. Create a Distance struct that will represent distance in various units of measurement. At a minimum, it should have a meters property and a feet property. Create a custom initializer corresponding to each property (i.e. if you only have the two properties for meters and feet you will then have two initializers) that will take in a distance in one unit of measurement and assign the correct value to both units of measurements. Hint: 1 meter = 3.28084 feet. Example If you use the initializer for meters and pass in a distance of 1600, the initializer should set meters to 1600 and feet to 5249.344. Now create an instance of Distance called mile. Use the initializer for meters to set the distance to 1600. Print out the property for feet and verify that it is equal to 5249.344. Now create another instance of Distance and give it some other distance. Ensure that both properties are set correctly. Previous | page 4 of 10 | Next: Exercise - Methods
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY