Docsity

Do-While Loop EXamples, Assignments of Java Programming

Partial preview of the text

Download Do-While Loop EXamples and more Assignments Java Programming in PDF only on Docsity!

SALCEDO, Eunice Marian J.

BSCE 2-

MT 9:30-11:00 AM

Computer Fundamentals and Programming 2

JAVA PROGRAM 1:

SOURCE CODES

OUTPUT

EXPLANATION

This program will be able to display numbers from 11 to 20. I specifically chose these numbers as

they have personal meanings to me. The program will execute in the following manner. First, the

program starts. 'i' is initialized with value 11. Execution enters the loop and 11 is printed as 'i' is

increased to 12. When i is increased to 12, condition is checked. 12 <= 20 yields true so 12 is

printed and i is increased to 13. Again, condition is checked. 13 <= 20 yields true so 13 is printed.

'i' is increased to 14 and condition is checked. 14 <= 20 yields true so 14 is printed. 'i' is increased

to 15 and condition is checked. 15 <=20 yields true so 15 is printed. The process is repeated until

'i' is increased to 20 since 20 <= 20 is still true. When 'i' is increased to 21, the loop is terminated

because 21 <= 20 is false.

JAVA PROGRAM 2:

SOURCE CODES