[Solved] CSc20: Programming Concepts And Methodology II Lab 07

$25

File Name: CSc20:_Programming_Concepts_And_Methodology_II_Lab_07.zip
File Size: 499.26 KB

SKU: [Solved] CSc20: Programming Concepts And Methodology II Lab 07 Category: Tag:
5/5 - (1 vote)

Objective:

The objective of this lab is to get you some experience in testing, debugging and exception handling.

The lab assignment:

  1. Test your infix evaluator program with the following test cases.
  1. 12 + (34 56) * 78 )
  2. 12 + (( 34-56) * 78
  3. 12 + 34 56
  4. 12 + * 34
  1. Obviously, you will either get an exception or wrong output for each of the test cases.
  1. If the test case produces an exception, you can locate the error from the call stack trace generated by the JVM. Example,

Exception in thread main java.lang.ArrayIndexOutOfBoundsException: -1 at StackQueue.Stack.pop(Stack.java:10) at infix.evaluePostfix(infix.java:59) at infix.main(infix.java:83)

  1. Insert code into your program to catch the exception and, throw, catch, and print your own exceptions.
  1. If the test case doesnt produce any exception, use jdb to step through you program in order to locate the error.
  1. Insert some error checking code to throw, catch, and print your own exceptions
  1. Your new program should produce outputs similar to the following.

D:lab05>java infix2

Enter infix: 12 + (34 56) * 78 )

***** Too many ) *****

Enter infix: 12 + (( 34-56) * 78

***** Too many ( *****

Enter infix: 12 + 34 56

Postfix is 12 34 56

***** Too many operands *****

Enter infix: 12 + * 34

Postfix is 12 34 *

***** Too many operators *****

Notes:

  1. You must use jdb for at least one test case.
  1. Open two athena windows.
  2. In one window, do java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=20000 infix
  3. In the other window, do jdb -attach 20000
  1. Use command script to record a jdb session.
  1. To get whole credit for this lab:
  1. Demo with the four test cases and 12+34*(56-7)-18/9.
  2. Turn in a hardcopy of infix.java.
  3. Email a softcopy of java and the file typescript.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CSc20: Programming Concepts And Methodology II Lab 07
$25