You Are Hired!
What is mathematical model?
====
Coding standards:
- { goes on the same line as condition
- Code indented 4 spaces
- } goes on a new line
====
====
You are hired by Megan Investment Bank to create an investment software to calculate a total return with the following input parameters:
1. Initial Investment
2. Number of day invest
3. Return per day
totalReturn = numberOfDayInvest * returnPerDay - initialInvestment
Your software recommends the following:
1. If totalReturn is > to initialInvestment and numberOfDayInvest < 4
Print "Good Investment"
Print "Your total return is: $"
2. If totalReturn is < initialInvestment and numberOfDayInvest = < 4
Print "Bad Investment"
Print "Your total return is: $"
====
- for-in: when you know how many times loop run
for number in 1...4 {
print("My name is Megan")
print(number)
print("And the value is \(number) \n")
}
- 1...4 : Closed range (each time it goes thru we say it iterates and each cycle is iteration)
- ... is Closed range operator
- \n a new line
- for-in with array:
let kidsInClass = ["Natalie", "Megan", "Stephanie", "Joleen", "Ashton", "Nhi", "Bao"]
for kidsName in kidsInClass {
print("Good morning \(kidsName)")
//print("Good morning \(kidsInClass)")
}
==============
Homework:
Write a program say hi to all your friends in the class 3 times using nested for-in loop
- Review array, operators, if and case conditional statements
- Study the for-in and vocabulary (i.e.. iteration, iterates, cycle)