BuiltWithNOF
Practice Final

1. Put your final correct answer for the output in the box provided:
intA = 5; intB = 1; intC = 8;       
   while (intB < intC)
{
   System.out.println ("yes" + intC);
   intB = intB + 1;
     if (intA > 3)
{
   System.out.println ("more");
   while (intA > intB)
{
   System.out.println ("do it" + intB);
   if (intB < 4)
{
   intC = intC - 1;
   System.out.println (intC);
   if (intA == 5)
{
   System.out.println ("done");
}
   System.out.println ("finish");
   }
   intB++;
   intA-=1;
   }
   System.out.println ("stop" + intB);
}
   if (intC < 3)
{
   System.out.println ("junk");
   intC = intC - 1;
}
   intC--;
   }

2. Suppose n = { 34,  21, 7, 18,  56, 24,  4,  9,  12, 78}  and x = {3,  1,  2,  5,  4}

What is    n[  x[  n[2] - x[3] ] + 2 ] -1      ______________

What is    x[  n[  x[2]  ] -  x[ n[1] - n[3] ]   ]     ____________________

What is the output for the following:      for (int a = 1; a < 5; a++)
Lst.AddItem( String.valueOf( n[ x [ a-1] ] );






3. Put the output for the following applet in the box provided:
int board[][];     int row,col;
public void paint(Graphics g)
{
board = new int[3][4];
board[0][1]=7;
for (int x=0; x<3; x++)
for (int y=2; y<4; y++)
{
if (x>0) board[x][y-2] = x+1;
if (x<y) board[x][y] = x*y;
else (board[x][y] = x-y+5);
}

for (int r=0; r<3; r++)
for (int c=0; c<4; c++)
g.drawString(String.valueOf(board[r][c]),c*20,r*20+20);
}

4. Put the output for the following code in the box provided. Assume you have List Output made.

public String a = "7";      
public String b = "3";  

public void start()
{
String c = "4";
String d = "5";
Output.addItem(a+b+c+d);
a = "2";
sec(a,c);
Output.addItem(a+b+c+d);
}

public void sec(String c, String d)
{
String a = "6";
Output.addItem(a+b+c+d);
 c = third(b,a);
Output.addItem(a+b+c+d);
}

public String third( String d, String c)
{
Output.addItem(a+b+c+d);
a = "8";
String b = "9";
Output.addItem(a+b+c+d);
return b;
}


7. List the 6 things a computer can do.
1.2.3.
4.5.6.


8. Diagram the programming process.


9. Diagram and label a computer.




Suppose you have a filled array of integers called n.  Write a Java method called Junk that passes in an integer and returns with how many elements in the array are above the average and more than this passed integer below the highest value in array n.  For example,  if you call Junk(5), you will return with how many numbers in the array are above the average and more than 5 below the highest value.

 

Write a Java Application to get pairs of numbers from the user until both numbers are equal. For each pair of numbers, tell which one is bigger.  If the difference between the two numbers is more than 10, then get a 3rd number, and if that number is between the first 2, then output the word “between”. When the loop is exited (both the first and second numbers are equal) then print the highest first number, the average of all the second numbers, and how many times the first number was bigger.

[Java at Evergreen] [Syllabus] [To Do List] [Lessons/Programs] [Evaluation/Review] [Help] [FAQ/GWIFO] [Discuss/Reports] [Resources] [Readings] [Portfolio] [Instructor]