/**
* 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 have 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 = ________

String w1 = "dictionary", w2 = "" ;
for ( i = ( w1.length ( ) - 1 ) ; i >= 0  ; i-- ) {
w2 += w1.charAt ( i );
}
/*4)*/ System.out. println ( "4) " + w2 ) ;

String s1 = "bob", s2 = "Bob" ;
/*5)*/ System.out. println ( "5) " + s1.compareTo ( s2 ) ) ; // outputs ____________ .

if ( s1.compareTo ( s2 ) > 0 ) {
String temp = s2 ;
s2 = s1 ;
s1 = temp ;
}
/*6)*/ System.out. println ( "6) " + s1 + ", " + s2 ) ;

int array [ ] = {4, 5, 6, 7, 8};
/*7)*/ System.out. println ( "7) " + array[2] ) ;

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

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

boolean a = true, b = false, c = false, booleanAnswer;
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.

/* _____  10 */ booleanAnswer = !a && b && i < j && j > k && c;

/* _____  11 */ booleanAnswer = !a || b || j == k && j != (k - 1);

/* _____  12 */ booleanAnswer = !(a || b || c) && a && i >= k * i % 2;

/* _____  13 */ booleanAnswer = !(b || a) && c && (i == j % 2 + 1);

/* _____  14 */ booleanAnswer = !!!(!a || !(b && !c));

/* _____  15 */booleanAnswer =!c || a || k <= j / i;

/* _____  16 */booleanAnswer = k <= j / (i*i) * 3 % k + j;

/* _____  17 */booleanAnswer =!c || !a || !(k >= j * (j/ i));

/* _____  18 */ doubleAnswer =  (int) (zz / y) + 42 / ( 221 % 2) * (50002 %2);

/* _____  19 */ doubleAnswer =  (double)i * (i / k)+ i *i * (int) (1/3) +1;

// _____ 20) List a wrapper class.

// _____ 21) Which of the following could be a valid data type for an ArrayList?
//             a) int   b)boolean  c) double  d) Double   e) all the answers

int ans [ ] = new int [5];
/* 22) */ System.out.println ( "22) " + ans [ 2 ]);
/* 23) */ System.out.println ( "23) " + addUp1(5));

/* 24) */ System.out.println ( "24) " + mystry1(4));

double twoDArray [ ] [ ] =
{
{0.0, 2.7, 5.6},
{4.3, 1.4, 7.2}
};

/* 25) */ System.out.println ( "25) " + twoDArray.length ) ;

/* 26) */ System.out.println ( "26) " + twoDArray[0].length ) ;

/* 27) */ System.out.println ( "27) " + twoDArray [ 1 ] [ 2 ] ) ;

/* 28)*/ System.out.println ( "28)" ) ;
mystry2 ( 3, 3 ) ;

}
public static int addUp1 (int n) {
if ( n == 3 )return 1 ;
return 2 * n * addUp1 ( n-1 ) ;
}

public static int mystry1 ( int y ) {
if ( y == 1 ) return 2 ;
else {
int x = mystry1 ( y/2 ) ;
System.out.println ( "y = " + y + ", x = " + x ) ;

x *= x;
if ( y % 2 == 1 ) x *= 4 ;
System.out.println ( "y = " + y + ", x = " + x + "\n" ) ;

return x + 1 ;
}
}

public static int mystry2 ( int r, int c ) {
System.out.print ("x " );
if ( c <= 1) {
c = r;
r--;
System.out.print ("\n" );
}

if ( r == 0 ) return 0;
return mystry2 ( r, c-1 ) ;
}
}