Warning:
|
mkdir ~/cs170/hw8 cp ~cs170002/share/hw8/* ~/cs170/hw8 cd ~/cs170/hw8 |
|
Use the file hw8.ans to answer the questions 1 through 5 (each question is worth 10 pts).
Use the file EvalExpr.java to do question 6 (50 pts).
(You can use gedit to edit the file - add your answer to the file. You will turn in the updated hw8.ans as part of this homework)
What is the scope of the variable i ? (Describe it with your own words)
Hint: compile the program, look at the error messages and draw your conclussion on the scope of the variable i)
|
The character array is a sequence of characters, which is nothing more than a string (in fact, the C/C++ programming language use character arrays to represent strings)
|
|
I have included a test program called TestEvalExpr.java.
The TestEvalExpr.java program contains a main() method that invoke the EvalExpr.eval() method.
Test your eval() method as follows:
UNIX>> javac TestEvalExpr.java UNIX>> java TestEvalExpr 1+2=3 2-3-4=-5 3+1-3-1+4-1=3 4+1-1+1-1+1-1=4 Illegal operator: / 4/1-1+1-1+1-1=0 Illegal operator: / 4+1-1/1-1+1-1=0 |
|
|