App Exercise - Type Properties and Methods Note These exercises reinforce Swift concepts in the context of a fitness tracking app. In another exercise, you added a computed property representing the average mile time from a run. However, you may want to have a calculator of sorts that users can use before their run to find out what mile time they need to average in order to run a given distance in a given time. In this case it might be helpful to have a type method on RunningWorkout that can be accessed without having an instance of RunningWorkout. Add to RunningWorkout a type method mileTimeFor(distance:time:) where distance and time are both of type Double. This method should have a return value of type Double. The body of the method should calculate the average mile time needed to cover the passed in distance in the passed in time. Assume that distance is in meters and that one mile is 1600 meters. Call the method from outside of the struct and print the result to ensure that it works properly. struct RunningWorkout { var distance: Double var time: Double var elevation: Double It may be helpful to have a few type properties on RunningWorkout representing unit conversions (i.e. meters to mile, feet to meters, etc.). Go back and add a type property for meterInFeet and assign it 3.28084. Then add a type property for mileInMeters and assign it 1600.0. Print both of these values below.

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 problem using Swift code? 10 of 10

App Exercise - Type Properties and Methods
Note
These exercises reinforce Swift concepts in the context of a fitness tracking app.
In another exercise, you added a computed property representing the average mile time from a run. However, you may want to have a calculator of sorts that users can use
before their run to find out what mile time they need to average in order to run a given distance in a given time. In this case it might be helpful to have a type method on
RunningWorkout that can be accessed without having an instance of RunningWorkout.
Add to RunningWorkout a type method mileTimeFor(distance:time:) where distance and time are both of type Double. This method should have a return value
of type Double. The body of the method should calculate the average mile time needed to cover the passed in distance in the passed in time. Assume that distance is in
meters and that one mile is 1600 meters.
Call the method from outside of the struct and print the result to ensure that it works properly.
struct RunningWorkout {
var distance: Double
var time: Double
12
13
14
15
var elevation: Double
16
}
17
18
19
It may be helpful to have a few type properties on RunningWorkout representing unit conversions (i.e. meters to mile, feet to meters, etc.). Go back and add a type
property for meterInFeet and assign it 3.28084. Then add a type property for mileInMeters and assign it 1600.0. Print both of these values below.
Transcribed Image Text:App Exercise - Type Properties and Methods Note These exercises reinforce Swift concepts in the context of a fitness tracking app. In another exercise, you added a computed property representing the average mile time from a run. However, you may want to have a calculator of sorts that users can use before their run to find out what mile time they need to average in order to run a given distance in a given time. In this case it might be helpful to have a type method on RunningWorkout that can be accessed without having an instance of RunningWorkout. Add to RunningWorkout a type method mileTimeFor(distance:time:) where distance and time are both of type Double. This method should have a return value of type Double. The body of the method should calculate the average mile time needed to cover the passed in distance in the passed in time. Assume that distance is in meters and that one mile is 1600 meters. Call the method from outside of the struct and print the result to ensure that it works properly. struct RunningWorkout { var distance: Double var time: Double 12 13 14 15 var elevation: Double 16 } 17 18 19 It may be helpful to have a few type properties on RunningWorkout representing unit conversions (i.e. meters to mile, feet to meters, etc.). Go back and add a type property for meterInFeet and assign it 3.28084. Then add a type property for mileInMeters and assign it 1600.0. Print both of these values below.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 2 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