Presentation is loading. Please wait.

Presentation is loading. Please wait.

Review for Final Exam. Scope 9 problems, 90 points. 1 Bonus problem (8 points) 120 minutes Java book – Main focus: Chapter 5, 8, 11, 13 (13.1 and 13.2).

Similar presentations


Presentation on theme: "Review for Final Exam. Scope 9 problems, 90 points. 1 Bonus problem (8 points) 120 minutes Java book – Main focus: Chapter 5, 8, 11, 13 (13.1 and 13.2)."— Presentation transcript:

1 Review for Final Exam

2 Scope 9 problems, 90 points. 1 Bonus problem (8 points) 120 minutes Java book – Main focus: Chapter 5, 8, 11, 13 (13.1 and 13.2). – However, it covers basic java programming concepts from other chapters (e.g., chapters before chapter 5) of the Java book. The Invitation to CS book – Chapter 6

3 Java programming Chapter 5 – Array declaration, element assignment, and accessing array elements – for loop and while loop – Array of objects Chapter 8 – Exception handling – Switch statement – Continue and break – Nested Loop Chapter 11 – Define a subclass – Super statement – Override method – Polymorphism Chapter 13 – Multidimensional array – Vector

4 Assembly Language Chapter 6 – Understand the assembly language instructions (no need to memorize them) – Read an assembly language program and understand what it does – Write code for simple problems – Symbol Table for an assembly language program – Translating an assembly language program into machine language instructions (see, e.g., figure 6.13 on page 302 of the textbook).

5 Problem Type Short answers (about 25%) Problem solving (about 25%) Practical coding writing (about 50%)

6 Grade Calculation Test 1 – 16% Test 2 – 20% Final exam – 24% HW Assignments – 40% (the lowest assignment grade fromHW1 to HW7 will not be counted). – 7 HW assignments (each one is 6 points), 1 Bonus HW assignment (also 6 points) – Since the lowest grades will not be counted, the base grade for HW is 36 (6 HW assignments)

7 Grade Calculation (cont.) Example: assume a student has the following grades: – Test1: 45 (out of 60); – test2: 50 (out of 60); – final exam: 74 (out of 90); – Homework assignments: HW1: 4; HW2: 6; HW3: 5; HW4: 6; HW5: 6; HW6: 1; HW7: 5; Bonus HW: 5 For the homework grades, the student gets 4+6+5+6+6+5+5(bonus)=37 (out of 36, which is the base grade for HW). The student’s total grade is: 45/60 * 16 + 50/60 * 20 + 74/90 * 24 + 37/36*40 = 12 + 16.7 + 19.7 + 41.1 = 89.5.

8 Exercise Problem 1 Consider the following assembly language program:.BEGIN Loop:INX INY LOADX COMPAREY JUMPGTDONE OUTX JUMPLOOP DONE:OUTY HALT X:.DATA0 Y:.DATA0.END Q1: What is the function of this program? It reads input x and y. If y >x, output y and the programs finishes; otherwise, output x and reads another set of x and y… Q2: What value is entered in the symbol table for the symbols LOOP, DONE, X, and Y? See Figure 6.10 on page 298 of the textbook. Q3: What is the machine language representation of this program (Assume the op code field is 4bits wide, the address filed is 12bits wide)? See Figure 6.13 on page 302 of the textbook.

9 Exercise Problem 2 Assuming Account is an existing class defined below. public class Account{ private double balance; public Account(double initialBalance){ balance = initialBalance; } public boolean deposit(double amount){ balance+=amount; return true; } public double getBalance(){ return balance; }

10 Exercise Problem 2 (cont.) Q1: Suppose accountArray is a variable of type Account[ ] to store an array of Account objects. Declare the accountArray variable to store 15 Account objects. Create 15 Accounts objects with random initial balance between 0 and 100 and store the objects in the accountArray array. Account[] accountArray = new Account[15]; for( int i= 0;i<15; i++){ Account acct = new Account(100*Math.random()); accountArray[i] = acct; } Q2: Write a code segment to find the account with the largest balance in the accountArray, and print out the balance for that account. double maxB = accountArray[0].getBalance(); int maxIndex = 0; for( int i= 1;i<15; i++){ double tempB = accountArray[i].getBalance(); if (temp > maxB){ maxB = tempB; maxIndex = i; } } System.out.println(accountArray[maxIndex ].getBalance());

11 Exercise Problem 2 (cont.) Q3: Suppose we want to use a Vector (named as accountVector) to store Account objects. Implement the same function as described in Q1: Vector accountVector = new Vector(); for( int i= 0;i<15; i++){ Account acct = new Account(100*Math.random()); accountVector.addElement(acct); } Q4: Write a code segment to find the account with the largest balance in the accountVector, and print out the balance for that account. Account acct = (Account) accountVector.elementAt(0); double maxB = acct.getBalance(); int maxIndex = 0; for( int i= 1;i<15; i++){ Account tempAcct = (Account) accountVector.elementAt(i); double tempB = tempAcct.getBalance(); if (temp > maxB){ maxB = tempB; maxIndex = i; } } System.out.println((Account) accountVector.elementAt(maxIndex).getBalance());

12 Exercise Problem 3 All problems in test1 and test2.

13 Java programming Demo based on my research projects


Download ppt "Review for Final Exam. Scope 9 problems, 90 points. 1 Bonus problem (8 points) 120 minutes Java book – Main focus: Chapter 5, 8, 11, 13 (13.1 and 13.2)."

Similar presentations


Ads by Google