Question: Goal: Learn to write for loops. Assignment: In a new mobile game, players earn points by overcoming obstacles. Each level has an increasing number of
Goal: Learn to write for loops.
Assignment: In a new mobile game, players earn points by overcoming obstacles. Each level has an increasing number of obstacles, and the points earned for each obstacle in a level are equal to the square of the level number. The game designer needs to calculate the total points that can be earned from the first levels to adjust the game's difficulty.
Given int variables level and totalPoints, use a for loop to compute the total points a player can earn by completing all obstacles in the first levels. The points from each level are the square of the level number multiplied by the number of obstacles in that level assume each level has obstacles equal to the level number Store this cumulative point total in totalPoints.
For example, level has obstacle worth points, level has obstacles each worth points totaling points for level and so on You must use level for your for loop.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
