/**
* First Semester Practice Exam
*
* @author TK Rogers
* @version 01-06-11
*/
public class FirstSemesterPracticeExam  {
public static void main ( ) {
int i = 0, k = 0, z = 2, n1 = 3, n2 = 3, t = 0 ;
// Give the values of the variables after the loops hav run.///////////////////////////////
for ( i=0; i<=n1; i++ ) {
for ( k=0; k<n2; k++ ) {
z += 2 ;
}
}
System.out.println ( "1) i = "+i  +";  k = "+k  +";  z = "+z ) ;

/1) i = ________    k = ________    z = ________

n1 = 3; n2 = 3; z = 1;
for ( i=1; i<=n1; i++ ) {
for ( k=1; k<=n2; k++ ) {
z *= k;
}
}
System.out.println ( "2) i = "+i  +";  k = "+k  +";  z = "+z ) ;

// 2) i = ________    k = ________    z = ________

n1 = 2; n2 = 2; z = 1 ;
for ( i=1; i<=n1; i++ ) {
for ( k=1; k<=n2; k++ ) {
z *= 3 ;
}
k = 12 ;
}
System.out.println ( "3) i = "+i  +";  k = "+k  +";  z = "+z ) ;

// 3) i = ________    k = ________    z = ________

// 4) What is the decimal equivalent of the binary number 11?  ____________

// 5) An array is initialized as follows: int array [ ] = {4, 5, 6, 7, 8}; What is the value
//     stored in array{2} ? ____________

// 6) Name one of the four classes contained in the java.lang package which are automatically
//     imported into your java programs. _____________________

// 7) A static method from a different class is called using ____________________.

boolean a = true, b = false, c = false, booleanAnswer ;
int     j = 4, intAnswer ;
i = 6; k = 4;
double  x = 1.0, y = 3.0, zz = 6.0, doubleAnswer ;

// Evaluate the  expressions and correctly write a T or F for in the blank provided.

/* _____  9 */ booleanAnswer = !a && b && i < j && j > k && c ;
System.out.println ( "9) " +booleanAnswer ) ;

/* _____  10 */ booleanAnswer = !a || b || j == k && j != (k - 1) ;
System.out.println ( "10) " +booleanAnswer ) ;

/* _____  11 */ booleanAnswer = !(a || b || c) && a && i >= k * i % 2 ;
System.out.println ( "11) " +booleanAnswer ) ;

/* _____  12 */ booleanAnswer = ! ( b || a ) && c && ( i == j % 2 + 1 ) ;
System.out.println ( "12) " +booleanAnswer ) ;

/* _____  13 */ booleanAnswer = !!! ( !a || ! ( b && !c ) ) ;
System.out.println ( "13) " +booleanAnswer ) ;

/* _____  15 */ booleanAnswer =!c || a || k <= j / i ;
System.out.println ( "17) " +booleanAnswer ) ;

/* _____  16 */ booleanAnswer = k <= j / ( i*i ) * 3 % k + j;
System.out.println ( "18) " +booleanAnswer ) ;

/* _____  17 */ booleanAnswer =!c || !a || !( k >= j * ( j /  i ) ) ;
System.out.println ( "19) " +booleanAnswer + "\n\n" ) ;

/* _____  18 */ doubleAnswer =  (int) ( zz / y ) + 42 / ( 221 % 2 ) * ( 50002 %2 ) ;
System.out.println ( "24) " +doubleAnswer ) ;

/* _____  19 */ doubleAnswer =  (double) i * ( i / k )+ i *i * (int) ( 1/3 ) +1;
System.out.println ( "25) " +doubleAnswer ) ;

// _____ 20) List a wrapper class.

// _____ 21) The hexadecimal number AA = _______________ in decimal.

// _____ 22) The binary number 101 = _______________ in decimal.

/* _____  23 */ System.out.println("27) " +addUp1(5));

/* _____  24 */ System.out.println("29) " +mystry(4));
}
public static int addUp1 ( int n ) {
if ( n==3 ) return 1 ;
return 2 * n * addUp1 ( n-1 ) ;
}

public static int mystry ( int y ) {
if ( y==1 )  return 2 ;
else  {
int x = mystry ( y / 2 ) ;
x *= x;
if ( y%2 == 1 )  x *= 4 ;
return x + 1 ;
}
}
}