import javax.swing.JOptionPane;
public class PossitiveNegative{
public static void main(String[]args){
int N1, N2, product, PoNoN1, PoNoN2;
String N1Str, N2Str, productStr, OutputPoNoN;
N1Str=JOptionPane.showInputDialog("Enter a number :");
N1=Integer.parseInt(N1Str);
N2Str=JOptionPane.showInputDialog("Enter another number :");
N2=Integer.parseInt(N2Str);
product=N1*N2;
if (N1>0)
PoNoN1=N1+"(POSITIVE)";
else if (N1<0)
PoNoN1=N1+"(NEGATIVE)";
else
PoNoN1="(NEUTRAL)";
if (N2>0)
PoNoN2=N2+"(POSITIVE)";
else if (N2<0)
PoNoN2=N2+"(NEGATIVE)";
else
PoNoN2="(NEUTRAL)";
if (product>0)
productStr=product+"(POSITIVE)";
else if (product<0)
productStr =product+"(NEGATIVE)";
else
productStr="(NEUTRAL)";
OutputPoNoN="First number :" + PoNoN1 + "\n" +
"Second number :" + PoNoN2 + "\n" +
"Product :" + product + productStr;
JOptionPane.showMessageDialog(null,OutputPoNoN,"Result :",JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
}
}
the result does not determining if the first and second integers are positive/negative/neutral
I have replace a variable instead of using System.out.print ( in the if else code pportion ) so the result will not show in the below of the IDE output view ( I wanted to place it on the show message dialog )
the problem is simple but as a beginner I am having difficulty.
thanks for any help.