Question: Program 3 - Swift let individualScores = [55, 26, 103, 92, 14] let bonusScore = 5 let baseScore = 2 var teamScore = 0 print

 Program 3 - Swift let individualScores = [55, 26, 103, 92,14] let bonusScore = 5 let baseScore = 2 var teamScore =0 print ("Checking scores: \\ (individualScores) ") for score in individualScores print

Program 3 - Swift let individualScores = [55, 26, 103, 92, 14] let bonusScore = 5 let baseScore = 2 var teamScore = 0 print ("Checking scores: \\ (individualScores) ") for score in individualScores print ("Checking score \\(score) ") if score > 50 { teamScore += bonusScore } else { teamScore += baseScore print (teamScore)Program 3: 1. What will be output to the terminal when the program is run? Hint: make sure you have traced all print statements along the program flow. The first two print-out lines are ,1, given as below. Checking scores: [55, 26, 103, 92, 14]l Checking score 55 2. How many iterations will be run by the for loop of the program? How did you figure this out? How does this for loop in a Swift program work in the same mechanism of providing repetition dynamics compared to the one you learnt in a C++ program? 3. Regarding individualScores, bonusScore, baseScore, and teamScore, are they used as a variable or constant in the given Swift program? Give your answer in the following table. Identifier Is it used as a variable or constant? individualScores bonusScore baseScore teamScore 4. What do you think the difference is between the keywords let and var? Hint: Deduce from how they are used in the program. Think about whose value will ever be adjusted throughout the program

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!