I don't know why the code cannot run. The compiler only said the "p cannot be resolved to a variable" and "q cannot be resolved to a variable" on Line 45. I have search the solution on the internet, but still no have a good way to solve this.
import javax.swing.JOptionPane;
public class Rumus_GUI
{
public static void main(String[] args)
{
int a = Integer.parseInt(JOptionPane.showInputDialog("PLEASE ENTER THE VALUE OF A"));
int b = Integer.parseInt(JOptionPane.showInputDialog("PLEASE ENTER THE VALUE OF B"));
int c = Integer.parseInt(JOptionPane.showInputDialog("PLEASE ENTER THE VALUE OF C"));
if (a==0)
{
JOptionPane.showMessageDialog(null,"THE VALUE OF A CANNOT BE 0.");
}
else
{
if (b<=-1)
{
String p = "xx";
}
else if (b==0)
{
String p = "";
}
else if (b>=1)
{
String p = "xx+";
}
else if (c<=-1)
{
String q = "x";
}
else if (c==0)
{
String q = "";
}
else
{
String q = "x+";
}
JOptionPane.showMessageDialog(null,"YOUR QUADRATIC EQUATION IS : "+a+p+b+q+c+"=0");
}
}
}