Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction To Programming Information Technology , 1’st Semester

Similar presentations


Presentation on theme: "Introduction To Programming Information Technology , 1’st Semester"— Presentation transcript:

1 Introduction To Programming Information Technology , 1’st Semester
MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE Using Java Introduction To Programming Information Technology , 1’st Semester Lecture 11 Repetition Statements Practices Teacher: Mahmoud Rafeek Alfarra

2 Practice 1 Identify and correct the errors in each of the following pieces of code. int x = 1, total; while ( x <= 10 ) { total += x; ++x; } Presented & Prepared by: Mahmoud R. Alfarra

3 Practice 1 Identify and correct the errors in each of the following pieces of code. while ( x <= 100 ) total += x; ++x; while ( y > 0 ) { System.out.println( y ); ++y; Presented & Prepared by: Mahmoud R. Alfarra

4 Practice 1 Identify and correct the errors in each of the following pieces of code. for ( i = 100, i >= 1, i++ ) System.out.println( i ); The following code should output the odd integers from 19 to 1: for ( i = 19; i >= 1; i += 2 ) Presented & Prepared by: Mahmoud R. Alfarra

5 Practice 1 Identify and correct the errors in each of the following pieces of code. The following code should print whether integer value is odd or even: switch ( value % 2 ) { case 0: System.out.println( "Even integer" ); case 1: System.out.println( "Odd integer" ); } Presented & Prepared by: Mahmoud R. Alfarra

6 Practice 1 Identify and correct the errors in each of the following pieces of code. The following code should output the even integers from 2 to 100: counter = 2; do { System.out.println( counter ); counter += 2 ; } While ( counter < 100 ); Presented & Prepared by: Mahmoud R. Alfarra

7 Practice 2 Trace the following program:
Presented & Prepared by: Mahmoud R. Alfarra

8 Practice 3 Trace the following program:
Presented & Prepared by: Mahmoud R. Alfarra

9 Practice 3 Trace the following program:
Presented & Prepared by: Mahmoud R. Alfarra

10 Practice 4 Trace the following program:
Presented & Prepared by: Mahmoud R. Alfarra

11 Practice 5 Trace the following program:
Presented & Prepared by: Mahmoud R. Alfarra

12 Practice 5 Trace the following program:
Presented & Prepared by: Mahmoud R. Alfarra

13 Practice 6 Write an application that finds the smallest of several integers. Assume that the first value read specifies the number of values to input from the user. Presented & Prepared by: Mahmoud R. Alfarra

14 Practice 7 Write an application that calculates the product of the odd integers from 1 to 15. Presented & Prepared by: Mahmoud R. Alfarra

15 Practice 8 Write an application that prints the following diamond shape. You may use output statements that print a single asterisk (*), a single space or a single newline character. Maximize your use of repetition, and minimize the number of output statements. Presented & Prepared by: Mahmoud R. Alfarra

16 More practices in the text book, chapters 4 and 5
Presented & Prepared by: Mahmoud R. Alfarra

17 Emank X Mezank من أعظم الاسباب التي ترفع درجة الإيمان للعبـد أن: يتق الله Presented & Prepared by: Mahmoud R. Alfarra

18 Next… Practices Presented & Prepared by: Mahmoud R. Alfarra


Download ppt "Introduction To Programming Information Technology , 1’st Semester"

Similar presentations


Ads by Google