Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Java *Please dont handwrite code* The attached java file is a short program that

ID: 3604290 • Letter: J

Question

Java *Please dont handwrite code*

The attached java file is a short program that implements a for loop. Add code to this program that implements a while loop for doing exactly the same thing as the provided for loop.

You will need to upload your .java file in answering this question.

public class Mid_Term_Loops {
/*
* Please provide the code for a while loop which does exactly the
* same thing as the below for loop.
*/
public static void main(String[] args) {
for(int i=22; i<=35; i++) {
System.out.println("counter: " + i);
}

}
}

Explanation / Answer

public class Mid_Term_Loops {

public static void main(String[] args) {

int i=22; //intialize i value as 22
while(i<=35){ // loop condition whether it is true the loop will continue otherwise terminate this loop
System.out.println("counter: " + i); // printing the i value
i++;// increment the i value
}

}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote