Using Java MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE Lecture 8 Decision Making Practices
Identify and correct the errors in each of the following sets of code:  if ( gender == 1 ) System.out.println( "Woman" ); else; System.out.println( "Man" );  while ( z >= 0 ) sum += z; 2Presented & Prepared by: Mahmoud R. Alfarra Practice 1
Identify and correct the errors in each of the following sets of code:  if ( age >= 65 ); System.out.println( "Age greater than or equal to 65" ); else System.out.println( "Age is less than 65 )";  int x = 1, total; while ( x <= 10 ){ total += x; ++x; } 3Presented & Prepared by: Mahmoud R. Alfarra Practice 1
Identify and correct the errors in each of the following sets of code:  while ( x <= 100 ) total += x; ++x;  while ( y > 0 ) { System.out.println( y ); ++y; } 4Presented & Prepared by: Mahmoud R. Alfarra Practice 1
Trace the following program, assuming x =5, y = 8 and x=8, y=5: 5Presented & Prepared by: Mahmoud R. Alfarra Practice 2
Determine the output for each of the given sets of code when x is 9 and y is 11 and when x is 11 and y is 9. 6Presented & Prepared by: Mahmoud R. Alfarra Practice 2
Determine the output for each of the given sets of code when x is 9 and y is 11 and when x is 11 and y is 9. 7Presented & Prepared by: Mahmoud R. Alfarra Practice 2
‫العزة‬ ‫رب‬ ‫يقول‬(‫ـه‬‫ن‬‫سبحا‬) (َ‫ل‬‫ا‬ ‫ـ‬َ‫ك‬ِّ‫ب‬َ‫ر‬ ‫اسم‬ ِّ‫ـح‬ِّ‫ب‬َ‫س‬‫ـى‬َ‫ل‬‫ـ‬ْ‫ع‬) 8Presented & Prepared by: Mahmoud R. Alfarra
Practices 9Presented & Prepared by: Mahmoud R. Alfarra

8 programming-using-java decision-making practices 20102011

  • 1.
    Using Java MINISTRY OFEDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE Lecture 8 Decision Making Practices
  • 2.
    Identify and correctthe errors in each of the following sets of code:  if ( gender == 1 ) System.out.println( "Woman" ); else; System.out.println( "Man" );  while ( z >= 0 ) sum += z; 2Presented & Prepared by: Mahmoud R. Alfarra Practice 1
  • 3.
    Identify and correctthe errors in each of the following sets of code:  if ( age >= 65 ); System.out.println( "Age greater than or equal to 65" ); else System.out.println( "Age is less than 65 )";  int x = 1, total; while ( x <= 10 ){ total += x; ++x; } 3Presented & Prepared by: Mahmoud R. Alfarra Practice 1
  • 4.
    Identify and correctthe errors in each of the following sets of code:  while ( x <= 100 ) total += x; ++x;  while ( y > 0 ) { System.out.println( y ); ++y; } 4Presented & Prepared by: Mahmoud R. Alfarra Practice 1
  • 5.
    Trace the followingprogram, assuming x =5, y = 8 and x=8, y=5: 5Presented & Prepared by: Mahmoud R. Alfarra Practice 2
  • 6.
    Determine the outputfor each of the given sets of code when x is 9 and y is 11 and when x is 11 and y is 9. 6Presented & Prepared by: Mahmoud R. Alfarra Practice 2
  • 7.
    Determine the outputfor each of the given sets of code when x is 9 and y is 11 and when x is 11 and y is 9. 7Presented & Prepared by: Mahmoud R. Alfarra Practice 2
  • 8.
    ‫العزة‬ ‫رب‬ ‫يقول‬(‫ـه‬‫ن‬‫سبحا‬) (َ‫ل‬‫ا‬‫ـ‬َ‫ك‬ِّ‫ب‬َ‫ر‬ ‫اسم‬ ِّ‫ـح‬ِّ‫ب‬َ‫س‬‫ـى‬َ‫ل‬‫ـ‬ْ‫ع‬) 8Presented & Prepared by: Mahmoud R. Alfarra
  • 9.
    Practices 9Presented & Preparedby: Mahmoud R. Alfarra