You are on page 1of 1

Answer 1## If I obtain an inaccurate answer, I have to check the code to make sure

it matches the code provided above.Common errors to avoid include


utilizing the incorrect loop limits or failing to update the "sum"
variable correctly within the loop.Make sure I use Curly Brackets
appropriately as well as ";" after the ends of every required line.

Answer 2## Total on the 1st iteration: 0 + 1 = 1


Total on the 2nd iteration: 1 + 2 = 3
Total on the 3rd iteration: 3 + 3 = 6
Total on the 4th iteration: 6 + 4 = 10
Total on the 5th iteration: 10 + 5 = 15
Total on the 6th iteration: 15 + 6 = 21
Total on the 7th iteration (before addition): 21

So, the value of the variable total on the 7th iteration, before the
addition step, is 21

Answer 3## To adhere to Java name rules, I changed int countstudent to int
countStudents. In order to make sure that it only counts the total
number of students once rather than each individual student, I also put the
countStudents++ line outside the loop.

You might also like