Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

// Computation.java This program calculates sum, difference, and product of two

ID: 3702732 • Letter: #

Question

// Computation.java This program calculates sum, difference, and product of two values. // Input: Interactive. // Output: Sum, difference, and product of two values. import javax.swing.* public class Computation public static void main (String args t3) double valuel; String value1String: double value2 String value2string: value1String JOptionPane. showInputDialog ("Enter first numeric value:) valuelDouble parseDouble (valueiString) value2String-JOptionPane.showInputDialog("Enter second numeric value:) value2 Double.parseDouble (value2String) i // Call calculateSum) here // Call calculateDifference ) here // Call calculateProduct) here System.exitton ) 1/ End of main1 method. // Write calculateSum() method here // Write calculateDafference () method here. // Write calculateProduct 1) method here. ) // End of Computation class

Explanation / Answer

hello,

So, the question is asking to take two numerical inputs from the user and display sum , difference and product of those inputs.

To display sum - call the function "calculateSum" and simply return the addition of the numbers(which was recieved as parameters) to the calling function.

To display difference - call the function "calculateDifference" and simply return the difference of the numbers(which was recieved as parameters) to the calling function.

To display difference - call the function "calculateProduct" and return the product of the numbers(which was recieved as parameters) to the calling function.

To display the output - we are inserting the results we have got from the above functions in the message dialog of JOptionPane.

As an example , please the below code : -

public class Computation {

   public static void main(String []args){

       double value1;

       String value1String;

       double value2;

       String value2String;

       value1String=JOptionPane.showInputDialog("Enter first numeric value : ");

       value1=Double.parseDouble(value1String);

       value2String=JOptionPane.showInputDialog("Enter second numeric value : ");

       value2=Double.parseDouble(value2String);

       double sum=calculateSum(value1,value2); // call to calculate sum

       double difference=calculateDifference(value1,value2); // call to calculate difference

       double product=calculateProduct(value1,value2); // call to calculate product

       JOptionPane.showMessageDialog(null, "sum :"+sum+" "+ "difference :"+difference+" "+"product :"+product); // for displaying output.

   }

   private static double calculateSum(double value1, double value2) {

       return value1+value2;

   }

   private static double calculateDifference(double value1, double value2) {

       return value1-value2;

   }

   private static double calculateProduct(double value1, double value2) {

       return value1*value2;

   }

}