Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complete problems #408

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
71 changes: 48 additions & 23 deletions MyPlayground.playground/Pages/main.xcplaygroundpage/Contents.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,79 +24,104 @@ let b = 32
/*: Question 1
### 1. Print the result of a greater than or equal to b
*/
// write your code here

print(a>=b)

/*: Question 2
### 2. Print the result of a modulo b is equal to zero
*/
// write your code here

print(a % b == 0)

/*: Question 3
### 3. Print the result of y times b less than or equal to a
*/
// write your code here

print(y * b <= a)

/*: Question 4
### 4. Print the inverse of a greater than or equal to b
*/
// write your code here

print(!(a >= b))


/*: Question 5
### 5. Print "true" if a modulo b is equal to zero
*/
// write your code here

if a % b == 0 {
print("true")
}

/*: Question 6
### 6. Print "true" if a divided by b is greater than x
*/
// write your code here

if Double(a / b) > x {
print("true")
}


/*: Question 7
### 7. Print "true" if y divided by x is greater than three, otherwise print false
*/
// write your code here

if Double(y) / x > 3 {
print("true")
} else {
print("false")
}



/*: Question 8
### 8. Print "true" if y is greater than x and a divided by b is greater than 9
*/
// write your code here

if Double(y) > x && (a / b) > 9 {
print("true")
}



/*: Question 9
### 9. Write a function "isGreater" that takes two Int arguments and returns true if the first is greater than the second and false if they're not
*/
// write your code here


func isGreater(num1: Int, num2: Int) -> Bool {
if num1 > num2 {
return true
} else {
return false
}
}




/*: Question 10
### 10. Write a function "isForceWith" that takes a String argument and returns true if the argument is the name of someone with whom the force is strong, and otherwise returns false. People who have the force are Luke, Leia, Anakin, Obi Wan, Yoda, Vader.
*/
// write your code here

func isForceWith(force: String) -> Bool {
if force == "Luke" {
return true
} else if force == "Leia" {
return true
} else if force == "Anakin" {
return true
} else if force == "Obi Wan" {
return true
} else if force == "Yoda" {
return true
} else if force == "Vader" {
return true
} else {
return false
}
}


/*: Question 11
### 11. Create a function where the two arguments represent different bank account (one of those bank accounts is yours). What type should these arguments be if we are to then perform some math operations on them? Setup a conditional that will add 10 to your funds and minus 10 from the other funds (bank account) if the other account won't go negative if we were to take 10 dollars from it.
*/
// write your code here

func bankTransfer(bank1: Double, bank2: Double) {
if bank2 >= 10 {
bank1 + 10
bank2 - 10
}
}



Expand Down