Need Help ?
Have a Question ?

(Solved): The Java Application Run Configuration Will Contain Two Program Arguments To Be Passed In. These Two ...

The Java application Run configuration will contain two program arguments to be passed in. These two arguments will be passed in when the program starts - for example, integers like 5 and 10.  This application will perform four operations on these two values: addition, subtraction, multiply & division and it will print out the results. 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 This class Calculate will contain two static public methods addition() and subtraction() which you call in the Main class using the Calculate class name. The Calculate class will also contain two non-static public methods multiply() and division() which you call using the Calculate object that you create. All these methods will accept two integers as input arguments and will return an integer result value.

Remember to call static methods just use the className.methodName() for example Calculate.addition(). To call non-static methods, you will need to first instantiate an object of that class then call the method using the object objectName.methodName() for example calc.addition() using the calc object you created first from the Calculate class.

Modify the main method in Lab7 to make calls to all four of the Calculate class 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. There should be only two classes in this IntelliJ solution Calculate and Main as shown below. To create a new Class just right click on your package (edu.psu.ist242) select New -> Java Class -> Calculate.

The output should look like this

Running Example using Program Arguments 5 10 Run + + Main /Library/Java/JavaVirtual Machines/jdk1.7. objc(1666]: Class JavaLa

Running Example using Program Arguments 5 10 Run + + Main /Library/Java/JavaVirtual Machines/jdk1.7. objc(1666]: Class JavaLaunchHelper is imp Addition result: 15 Subtraction result: -5 Multiplication result: 50 Division result: 0 L

Expert Answer

import java.util.Scanner; public class Calculator { public static void main(String[] args) { Scanner reader = new Scanner(; System.out.print("Enter two numbers:
We have an Answer from Expert Buy This Answer $6