I am a beginner in Java and my professor wants us to create a program that involves some math. The thing is that he wants the calculations in a separate method. Can someone please help me. The program will not run the result for some reason. I tried looking around this website and could not find the answer. Here is the code below:
import javax.swing.JOptionPane;
public class forFun {
public static void main(String[] args)
{
double x, y, z;
String xVal, yVal, zVal;
xVal = JOptionPane.showInputDialog("Enter first integer: ");
yVal = JOptionPane.showInputDialog("Enter second integer: ");
zVal = JOptionPane.showInputDialog("Enter third integer: ");
x = Double.parseDouble(xVal);
y = Double.parseDouble(yVal);
z = Double.parseDouble(zVal);
System.exit(0);
}
public static void sumOfStocks(double x, double y, double z)
{
double result = x * y * z;
System.out.println("The product of the integers is: " + result);
System.exit(0);
}
}
sumOfStocks(x, y, z);just before theSystem.exit(0);to make that method call.