Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
58 changes: 58 additions & 0 deletions CurrencyConverter.playground/Contents.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import UIKit


enum Currency {
case cad
case mxn

}

let usToCad = 1.41
let usToMxn = 23.93


let currency = Currency.mxn //currency type you are converting to

func convert(_ dollars: Double, currencyType: Currency) -> Double {

var convertedUSD: Double = 1.00

switch currencyType {
case .cad:
convertedUSD = dollars * usToCad

case .mxn:
usToMxn
convertedUSD = dollars * usToMxn


}

return convertedUSD
}

print(convert(10, currencyType: .cad))







func convert(amountString: String) -> String? {

let amount = Double(amountString)
guard let unwrappedAmount = amount else {return "connot convert to double"}



let newTotal = convert(unwrappedAmount, currencyType: .cad)

let newAmount = String(newTotal)



return newAmount
}
let convertedAmount = convert(amountString: "10")
print(convertedAmount as Any)
4 changes: 4 additions & 0 deletions CurrencyConverter.playground/contents.xcplayground
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<playground version='5.0' target-platform='ios'>
<timeline fileName='timeline.xctimeline'/>
</playground>