Skip to content

sarahalzhrani/day3-lab1

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 

Repository files navigation

Day3 Lab1: Swift Basics 2

Topics

  1. Optionals
  2. Dictionaries
  3. Conditionals
    • If
    • Switch
  4. Loops
  5. Reuse
    • Functions
    • Closures

Description

  1. Task 1 — Optionals
    • Create a variable which hold an optional value and assign nil to it
    • Print the variable if it is not nil
    • Assign the same variable a NOT nil value
    • Print the variable if it is not nil
  2. Task 2 — Loops
    • Create an array with 5 names
    • Print the names in the array using a loop
  3. Task 3 — Reuse
    • Create a function that takes a price and a discount value and returns the price after the discount
    • Print the value of the function when the price=100 & discount=0.5
    • Print the value of the function when the price=200 & discount=0.25
  4. Task 4 — Conditionals
    • Create a variable that holds a student GPA
    • If the GPA is above 3 print nice ;)
    • If the GPA is below 3 print not nice :(
    • If the GPA is 3 print nice and not nice :)
  5. Task 5 — Conditionals (Bonus 😉)
    • There is no universal rule about when to use if-else and when to use switch. Sometimes, we prefer one over the other just because of readability. Let's say, you typically get a bonus at the end of each year. Now you are making a plan for your next travel destination. Here is the plan:
      • If you get a bonus of $10000 (or more), you will travel to Paris and London.
      • If the bonus is between $5000 and $9999, you will travel to Tokyo.
      • If the bonus is between $1000 and $4999, you will travel to Bangkok.
      • If the bonus is less than $1000, you just stay home.
    • Write a Swift program that making a plan for your next travel destination based on the bonus at the end of each year

DeadLine

Tuesday 28 September

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Swift 100.0%