From 9a28726a66806e3895afbe021c8b2683ff023998 Mon Sep 17 00:00:00 2001 From: YasminAMassoud <55138409+YasminAMassoud@users.noreply.github.com> Date: Fri, 19 Jun 2020 14:29:02 +0200 Subject: [PATCH] Update Contents.swift --- .../Contents.swift | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Student Resources/1 - Getting Started/4 - Control Flow/lab/Lab - Control Flow.playground/Pages/3. App Exercise - Fitness Decisions.xcplaygroundpage/Contents.swift b/Student Resources/1 - Getting Started/4 - Control Flow/lab/Lab - Control Flow.playground/Pages/3. App Exercise - Fitness Decisions.xcplaygroundpage/Contents.swift index d0d23b3..4ee5f79 100644 --- a/Student Resources/1 - Getting Started/4 - Control Flow/lab/Lab - Control Flow.playground/Pages/3. App Exercise - Fitness Decisions.xcplaygroundpage/Contents.swift +++ b/Student Resources/1 - Getting Started/4 - Control Flow/lab/Lab - Control Flow.playground/Pages/3. App Exercise - Fitness Decisions.xcplaygroundpage/Contents.swift @@ -6,10 +6,25 @@ You want your fitness tracking app to give as much encouragement as possible to your users. Create a variable `steps` equal to the number of steps you guess you've taken today. Create a constant `stepGoal` equal to 10,000. Write an if-else statement that will print "You're almost halfway there!" if `steps` is less than half of `stepGoal`, and will print "You're over halfway there!" if `steps` is greater than half of `stepGoal`. */ +var steps = 1000 +let stepGoal = 10_000 +if steps < (stepGoal/2) +{ +print("you are halfway") +} else { + +print ("you are halfway there") + +} /*: Now create a new, but similar, if-else-if statement that prints "Way to get a good start today!" if `steps` is less than a tenth of `stepGoal`, prints "You're almost halfway there!" if `steps` is less than half of `stepGoal`, and prints "You're over halfway there!" if `steps` is greater than half of `stepGoal`. */ +if steps < stepGoal/10 { +print("good start ") } +else if +steps < stepGoal/2 { +print("almost halfway") } - +else { print("you are almost there")} //: [Previous](@previous) | page 3 of 9 | [Next: Exercise - Boolean Practice](@next)