I'm having trouble with one of the projects in the Java course and could use some help.
Hello everyone, I need some help. I'm currently working on the project at the end of Java module 3. This is what I have: function main() { var depth = parseInt(readLine(), 10); //your code goes here var i = 1 var p = 0 do { p+=7; i++; } while (p<depth); console.log(i); } This is my incomplete solution to the given problem. I was testing it to make sure it worked as intended. It did not, and I can't figure out why. 1: Depth in the tested case is equal to 42. The output for this function is 7, but I had expected it to be 6. That means this loop is running a seventh iteration, exiting the loop when p equals 49 instead of 42. Why is this loop running an extra time? 2:Though not imperative to my completion of the project, I still need an answer to this. As an experiment, I put "p+7" in place of "p+=7" and ran it. My curiosity was rewarded with a runtime error. Can someone explain why?