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

finsh homework #3

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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.
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,8 @@
//: Next, learn how programmers can leave notes in code.
//:
//:[Previous](@previous) | page 3 of 7 | [Next: Comments](@next)
22+55+9
11-2-3
4*81
80/22
(12+33+11)/4
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
//:
//: A comment starts with two slashes `//` :
// This is a comment; it does not affect the code
34 + 56 + 230
34 + 56 + 230//add
//: Because comments are ignored, no result is displayed in the results bar for that line of code.
// 200 + 34 + 45
200 + 34 + 45
//: - experiment:\
//: Try _commenting out_ the calculation `34 + 56 + 230` by adding two slashes to the beginning of the calculation.\
//:Try _uncommenting_ the calculation `200 + 34 + 45` by deleting the two slashes.\
Expand All @@ -19,3 +19,4 @@
//: Take a deep breath and move on to the next page.
//:
//:[Previous](@previous) | page 4 of 7 | [Next: When Things Go Wrong 😰](@next)
// addition
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//: This playground page, for example, has an error in it.
//:
//: 👈 Notice the red error symbol to the left of the line below. This is how a playground tells you where a problem is.
1000 / 0
1000 / 2
//: Since there is an error, the playground stops running your code.\
//: Notice that there are no results displayed in the sidebar. 👉
2 + 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Next, find out how to put the results sidebar to better use.

[Previous](@previous) | page 2 of 7 | [Next: Calculations](@next)
*/



12
43
3
7
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//: ## Exercise: Putting on a Show
//: Your friend is done with the pet show. With your help, it was a big success. Now your friend is putting on a concert. Tickets are for sale at $10 per ticket. The room rental is $50. Making posters for the show costs $40. Help your friend figure out if the show is going to make money or lose money.
// Number Of Tickets
//Number Of Tickets
150

// Ticket Price
Expand All @@ -22,7 +22,13 @@
(150 * 10) - (1000 + 40)
//: - callout(Exercise): Using the code above as a reference, use let statements to define constants to better solve your friend’s problem.\
//:Add your code below. To help you get started, the constant `numberOfTickets` is already defined.
let numberOfTickets = 150

//:
//:[Previous](@previous) | page 10 of 14 | [Next: Exercise: Lottery Tickets](@next)
let numberOfTickets = 150
let ticketPrice = 10
let roomRentalFee = 1000
let PosterCost = 40
let totalTicketvalue = numberOfTickets * ticketPrice
let totalExpenses = roomRentalFee + PosterCost
let TotalIncomeOfShow = totalTicketvalue - totalExpenses
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,22 @@ let programmersCut = profit / 10 // This is the answer you want to get over 100!
let friendsCut = profit - programmersCut

//:[Previous](@previous) | page 11 of 14 | [Next: Exercise: What Fits on Your iPhone?](@next)
let ticketsSold2 = 3400
let ticketPrice2 = 4
let printingCosts2 = 45
let advertising2 = 77
// Total takings
let totalTakings2 = ticketPrice * ticketsSold

// Jackpot
let jackpot2 = totalTakings / 2

// Expenses
let totalExpenses2 = printingCosts + advertising

// Profit
let profit2 = totalTakings - jackpot - totalExpenses

// Distribution
let programmersCut2 = profit / 10 // This is the answer you want to get over 100! 👉
let friendsCut2 = profit - programmersCut
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,10 @@


//:[Previous](@previous) | page 12 of 14 | [Next: Exercise: Fixing Your Morning](@next)
let iphonegb = 8
let megabytes = 1000
let iphonegbsize = 3
let iphonement = (iphonegb - iphonegbsize )
let videotakes = 150
let totalvideotakes = ( iphonement * megabytes )/videotakes

Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,16 @@
*/
let brushTeeth = 3
// Add more here...
let uploadPhotos=10
let chooseClothes=15
let shower=20
let goJogging = 30
let finishHomework = 30
let fixLunch = 45


//: - callout(Exercise): Find the total time of all the activities by adding up the constants. Try to adjust the values or add more activities until the total time looks reasonably close to the actual amount of time you spend getting ready on an average day.
let totl = brushTeeth+uploadPhotos+chooseClothes+shower+goJogging+finishHomework+fixLunch



Expand All @@ -17,6 +25,9 @@ let brushTeeth = 3
//:If there are things you don’t have to do and don't like to do, make a third group and go ahead and sum that one, too. \
//:\
//:Make a new constant for each group.
let Onadailybasis=chooseClothes+shower+goJogging+finishHomework

let youwanttodoit=brushTeeth+uploadPhotos+fixLunch



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,16 @@ let rhso = co - lhso


//: - experiment: Rewrite the code so that it makes sense without needing a note. Use meaningful names and comments.

let Box = 14
let watermelonloads = 3
let orangesweigh = 100
let watermelonsweigh = 200
let traceorangesweigh = Box * orangesweigh
let tracw = watermelonloads * watermelonsweigh
let watermelonransportcar = traceorangesweigh + tracw
let halfaloadofwatermelon = watermelonransportcar / 2
let leftload = halfaloadofwatermelon/orangesweigh
let rightload = Box - leftload



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
//: Swift will accept names like this without complaint. But imagine coming back to read that code after vacation. Would you remember what `nd` or `n1` meant? And if you gave the playground to other programmers, how would they figure out what those names were supposed to mean?
//:
//: - callout(Just for fun): In Swift, you can use emoji in names. This is not considered good naming practice, but it can be fun. Below is the pet problem redone using emoji for names.
//numberOfDogs + numberOfCats + numberOfTurtles + numberOfHamsters + numberofpotbellied + numberofish + numberosnake
let 🐶 = 8
let 🐱 = 4
let 🐹 = 2
Expand All @@ -26,3 +27,14 @@ let totalNumberOfMammals = 🐶 + 🐱 + 🐹 + 🐷
//: Next, learn the official names for the work you’ve been doing.
//:
//:[Previous](@previous) | page 7 of 14 | [Next: Programmer Talk](@next)
let numberOfDogs = 8
let numberOfCats = 4
let umberOfHamsters = 2
let numberOfTurtles = 3
let numberosnake = 1
let numberofpotbellied = 1
let numberofish = 1

let totalNumberOfAnimals2 = numberOfDogs + numberOfCats + umberOfHamsters + numberOfTurtles + numberosnake + numberofpotbellied + numberofish

let totalNumberOfMammals2 = numberOfDogs + numberOfCats + umberOfHamsters + numberofpotbellied
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,16 @@ let totalNumberOfMammals = numberOfDogs + numberOfCats + numberOfHamsters
//: Next, learn about choosing names.
//:
//:[Previous](@previous) | page 6 of 14 | [Next: Choosing Good Names](@next)
let numberOfDogs2 = 6 + 2

let numberOfCats2 = 5 - 1

let numberOfTurtles2 = 2 + 1

let numberOfHamsters2 = 1 + 1
let numberofpotbellied = 1
let numberofish = 1
let numberosnake = 1
let totalNumberOfAnimals2 = numberOfDogs + numberOfCats + numberOfTurtles + numberOfHamsters + numberofpotbellied + numberofish + numberosnake

let totalNumberOfMammals2 = numberOfDogs + numberOfCats + numberOfHamsters + numberofpotbellied
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,13 @@ let totalNumberOfMammals = numberOfDogs + numberOfCats + numberOfHamsters
//: Once you’re finished experimenting, move ahead.
//:
//:[Previous](@previous) | page 4 of 14 | [Next: Typing Names and Autocompletion](@next)
let numberOfDogs2 = 6+2

let numberOfCats2 = 5-1

let numberOfTurtles2 = 2+1

let numberOfHamsters2 = 1+1
let totalNumberOfAnimals2 = numberOfDogs + numberOfCats + numberOfTurtles + numberOfHamsters

let totalNumberOfMammals2 = numberOfDogs + numberOfCats + numberOfHamsters
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,19 @@
//: Could there be a better way to solve this problem? Think about it for a minute or two, then move on.
//:
//:[Previous](@previous) | page 2 of 14 | [Next: Pet Problem Recap](@next)
// Number Of Dogs
6

// Number Of Cats
5

// Number Of Turtles
2
// Number Of Hamsters
1

// Total Number Of Animals
6 + 5 + 2 + 1

// Total Number Of Mammals
6 + 5 + 1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<playground version='6.0' target-platform='ios' display-mode='rendered' executeOnSourceChanges='true'>
<playground version='6.0' target-platform='macos' display-mode='rendered' executeOnSourceChanges='true'>
<pages>
<page name='Introduction'/>
<page name='Pet Problem'/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ let finishedMessage = username + " " + likesYourPostMessage
//:Combine your `firstName` and `likesYourPostMessage`\
//:Type each line of code below the relevant comment below.
// Declare a firstName constant

let firstName = "abdualziz"

// Declare a lastName constant

let lastName = "albalwi"

// Combine the strings into a fullName constant

let fullName = firstName + " " + lastName

// Combine your first name with likesYourPostMessage

let postmasege = "likes your post"

//: Next, find out how building strings by adding them can get complicated.
//:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ let traditionalGreeting = "Hello, world!"
//: The declared string values also appear in the results sidebar. 👉
//: - experiment: Practice by declaring `favoriteMovie` and `favoriteSong` string constants for your favorite movie and song:
// Declare a favoriteMovie constant
let favoriteMovie = "the call"


// Declare a favoriteSong constant
let favoriteSong = "top 100 naems"


//: Next, take a string-based trip around the world.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ let tableTwoResponse = "Perfect, merci bien."

//:
//:[Previous](@previous) | page 14 of 16 | [Next: Exercise: Go! Fight! Win!](@next)
let serverResponseToTableTwo2 = "Let me make sure I've got this right: \(customerOrderFour),\(customerOrderFive),\(customerOrderSix)"
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,10 @@
_THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE._
*/
//:[Previous](@previous) | page 16 of 16
let iphonegb = 8
let megabytes = 1000
let iphonegbsize = 3
let iphonement = (iphonegb - iphonegbsize )
let videotakes = 150
let totalvideotakes = ( iphonement * megabytes )/videotakes
let masege = "You can record \(totalvideotakes) more minutes of video."
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,7 @@ let song = "\(refrain)\n\(refrain)\nYes, \(refrain)"

//:
//:[Previous](@previous) | page 15 of 16 | [Next: Exercise: Displaying Values](@next)
let schoolName2 = "university tabok"
let refrain2 = "hmm hmm HMMM hm-hmm \(schoolName2) hmm hmm HMMMMM"

let song2 = "\(refrain2)\n\(refrain)\nYes, \(refrain2)"
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,15 @@ let newline = "Making new lines"
/*:
- experiment: Make a new string constant that is a list of the things you’ve learned, with each entry on a new line. Make sure you add the result to the playground page so that you can see the list properly.
*/

let constants2 = "They were all outside the university"
let unicode2 = " (😁)"
let combining2 = constants2 + " " + unicode2
let interpolation2 = "\(constants2) \(unicode2)"
let escaping2 = "which university do you study in \"university tabok\""
let newline2 = """
what is your specialty؟
IT
"""



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ let goalieReportString = "At the game yesterday, \(goalieName) had \(firstHalfSa
Sample story: “Today was a big day for <name>. They had finally saved up <number> dollars and were going to buy a <adjective> <noun>. They went to the <noun> <place> feeling very <positive emotion>. But then they felt <negative emotion>. They were all out of <noun>!”
*/
// Add your version of the story below
let name = "abdualziz"
let number = 2
let neme2 = "salem"
let place = "supermarket"
let positiveemotion = "hapy"
let negativeemotion = "sad"
let place2 = "supermarket"
let string = "Today was a big day for\(name).They had finally saved up\(number)dollars and were going to buy a\(neme2).They went to the\(place)feeling very\(positiveemotion).But then they felt\(negativeemotion).They were all out of\(place2)"



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ let favoriteFood = "pie"
let reason = "tasty"

// Define a string below in the pattern "I like ___ because it is ___."

let post = "I like \(favoriteFood), because it is \(reason)"

//: On the next page, see what happens with long strings.
//:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ func rowTheBoat() {
What happens if you call your function more than once?

*/


func tabuk() {
print("Tuwaiq_Academy")

}
tabuk()



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ merrilyDream()
breatheBetweenVerses()
rowTheBoat()
//: - callout(Exercise): Write a function called `crocodileScream()` for the second two lines of the second verse, and call it to complete the song in the console.


func crocodileScream(){
print("merrilyDream()")
}
crocodileScream()



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,28 @@ verseThree()

[Previous](@previous) | page 9 of 12 | [Next: Wrapup](@next)
*/
func rowTheBoat2() {
print("Ride, ride, ride your bike")
print("With your cycling team")
}

func verseOne2() {
rowTheBoat2()
merrilyDream()
}

func verseTwo2() {
rowTheBoat2()
crocodileScream()
}

func verseThree2() {
rowTheBoat2()
repetitiveTheme()
}

verseOne2()
breatheBetweenVerses()
verseTwo2()
breatheBetweenVerses()
verseThree2()
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func laughingSubmarine() {
}

// Write the verse two function below

laughingSubmarine()

//: On the next page, learn about one of the things that can go wrong when using functions of functions.
//:
Expand Down
Loading