Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 ("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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started