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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
The goal of today's module project is to create a Currency Conversion playground that can convert from US dollars (USD) to Canadian dollars (CAD) and Mexican Pesos (MXN).

Get the currency conversion value from Google:
// get started

On August 7th, 2019 they were:

Expand Down
81 changes: 81 additions & 0 deletions swift Fundalmentals III.playground/Contents.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
//Bryan Cress
//currency converter
import UIKit


enum Currency {
case cad
case mxn
}


let usToCad = 1.14
let usToMex = 23.97

var currency: Currency = .cad



// this function helps convert the us dollar into the current price for the Candaian and Mexican dollar depending on which you pass though
func convert(_ dollars: Double, convertedCurrency: Currency) -> Double {
switch convertedCurrency {
case .cad:
return dollars * usToCad
case .mxn:
return dollars * usToMex
}
}


// if currency == Currency.cad {
// return dollars * usToCad
// } else {
// return dollars * usToMex
// }
//}


convert(100, convertedCurrency: .cad)





// this function converts a
func convert(amountString: String) -> String? {
guard let unwrappedAmount = Double(amountString) else {
return nil
}
let convertedString = convert(1, convertedCurrency: .mxn)
return String(convertedString)
}

convert(amountString: "1.00")




// stretch goal

var currencyFormatter: NumberFormatter = {
let formatter = NumberFormatter()
formatter.numberStyle = .currency
return formatter
}()

















4 changes: 4 additions & 0 deletions swift Fundalmentals III.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>

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Binary file not shown.