Question: Write a command - line program that accepts two numbers and a string representing an arithmetic operation: plus, minus, times, and div in either upper
Write a commandline program that accepts two numbers and
a string representing an arithmetic operation: "plus", "minus", "times", and
"div" in either upper or lower case and evaluates the resulting expression.
Examples of running the program source in Calc.java several times:
Chapter Immutable Objects
java Calc
Usage: number plusminustimesdiv number
java Calc plus
java Calc div
java Calc MINUS
The point of this exercise is to make sure you understand the mechanism for passing objects as parameters.
For the following program, draw a stack diagram showing the local variables and parameters of main and riddle just before riddle returns. Use arrows to show which objects each variable references.
What is the output of the program?
Is the blank object mutable or immutable? How can you tell?
public static int riddleint x Point p
x x ;
return x px py;
public static void mainString args
int x ;
Point blank new Point;
System.out.printlnriddlex blank;
System.out.printlnx;
System.out.printlnblankx;
System.out.printlnblanky;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
