Hi I am trying to ride a program that answers a mathematic equation but I keep getting the the error Exception in thread "main" java.lang.ArithmeticException: / by zero
at EquationCalc.main(EquationCalc.java:48)
I cannot get around it, does anyone have any ideas?
import javax.swing.JOptionPane;
/** This program will calculate an equation following the order of operations */
public class EquationCalc
{
public static void main(String[] args)
{
int a=0, b=0, c=0, d=0, e=0, f=0;
JOptionPane.showMessageDialog(null, "Order of operation!");//Stating purpose of program to user
//input first number
String temp1 = JOptionPane.showInputDialog(null,"Please enter a number.");
//convert to int
a=Integer.parseInt(temp1);
//input second number
String temp2 = JOptionPane.showInputDialog(null,"Please another number.");
//convert to int
b=Integer.parseInt(temp2);
//input third number
String temp3 = JOptionPane.showInputDialog(null,"Please another number.");
//convert to int
c=Integer.parseInt(temp3);
//input fouth number
String temp4 = JOptionPane.showInputDialog(null,"Please another number.");
//convert to int
d=Integer.parseInt(temp4);
//input fifth number
String temp5 = JOptionPane.showInputDialog(null,"Please another number.");
//convert to int
e=Integer.parseInt(temp5);
//input sixth number
String temp6 = JOptionPane.showInputDialog(null,"Please another number.");
//convert to int
b=Integer.parseInt(temp6);
JOptionPane.showMessageDialog(null, "We will now solve for the equation x = a + (double)b * (c / d) – e % f");
double x= a + (double)b * (c / d) - e % f;//user dialog box stating purpose
System.out.println( x+"="+a+"+"+(double)b+"*"+(c+"/"+d)+"-"+e+"%"+f);// prints out answer
}
}