Assignment: Control Statements
Task 1: Definitions & Concepts
Instructions: Answer the questions below.
1. Keywords: To you best knowledge, describe below words:
a. System.in
b. Break
c. While
2. List Java's selection statements:
3. What is a definite loop?
4. What is an infinite loop? How would you break one?
5. What is the difference between for loop and while loop?
6. When is a good time to use a do-while loop instead of a while loop?
7. Explain the difference between a using a break and a continue in a loop?
Task 2: Understanding Programming
Instructions: Answer each question below. Try to understand and explain the code. Do not put an IDE code screenshot.
1. Show the general if - else if - else ladder.
2. What is the difference between 5, ‘5',"5"?
3. Given
if(x < y)
if(y > 100) {
if(!done) x = z;
else y = z;
}
else System.out.println("error"); // what if?
To what if does the last else associate?
4. Show the for statement for a loop that counts from 2000 to 100 by -4.
5. Is the following fragment valid? Why or why not?
for(int i = 0; i < num; i++)
sum += i;
count = i;
6. What does the following fragment print?
for(int i = 0; i < 10; i++)
{
System.out.print(i + "");
if(i%2 == 0) continue;
System.out.println();
}
Task 3: Programming Exercises
Instructions: Use any IDE to write and execute below exercises from the book chapter 3. Attach Snipping photos of your source code and execution of the code in the console. Make sure to create separate files for each exercise.
Text Book: Java Programming- A Comprehensive Introduction by Herbert Schildt and Dale Skrien.
Format your assignment according to the following formatting requirements:
1. The answer should be typed, double spaced, using Times New Roman font (size 12), with one-inch margins on all sides.
2. The response also includes a cover page containing the title of the assignment, the student's name, the course title, and the date. The cover page is not included in the required page length.
3. Also include a reference page. The Citations and references should follow APA format. The reference page is not included in the required page length.
Attachment:- Lab-Control-Statements.rar