Question: Using the IST Linux Putty system (using the nano editor) create the following Java command line calculator application Lab2. I would just copy Lab1.java using
Using the IST Linux Putty system (using the nano editor) create the following Java command line calculator application Lab2. I would just copy Lab1.java using the cp linux copy command - cp Lab1.java Lab2.java Pass in two arguments from the Linux command line when the program starts. For example java Lab2 value1 value2. Replace value1 and value2 with integers like 200 100 - java Lab2 200 100 This will perform four operations on these values: addition, subtraction, multiply & division and print out the results - see the attached example. The two arguments get passed into the main method as a String array in the variable object named args. Remember they get passed in as strings so you need to parse them into integers using the Integer.parseInt(args[0]) before you can treat them as integers.
Create a new file Java class called Calculate.java. This class will contain two static public methods addition() and subtraction() and two non-static public methods multiply() and division(). These methods will accept two integers as input variables and will return an integer result value. Compile it with javac Calculate.java
In Lab2.java if you copied the file from Lab1.java then modify the Lab1 class identifier to be Lab2. Modify the main method to make calls to all the four methods addition(), subtraction(), multiply() and division() and print out the results to the terminal. Remember how you call static and non-static methods are different and you need to review my video and power point presentation. Please include the Java source code printout along with the program running in your pdf upload.
Your application will have two source files Calculate.java and Lab2.java - compile both of them using javac.
To run it use java Lab2 200 100
See the attached example. 
Joseph root@ist242:/home/Joe0akes# javac Calculate.java root@ist242:/home/Joe0akes# javac Lab2.java root@ist242:/home/Joe0akes# java Lab2 200 100 Addition result: 300 Subtraction result: 100 Multiplication result: 20000 Division result: 2
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
