Everything you need for your program can be
found at the Sun tutorials. After that, you just need a little mathematical logic.
Btw, please do not PM staff with code/logic issues. Other members are not off limits, so long as they approve of your PMs. But often, staff are busy manning the forum helms - besides you can get a lot of feedback from the forums vs. PMs.
Provided the code you PMed:
import javax.swing.JOptionPane;
public class MathData1 {
public static void main(String[] args) {
JOptionPane.showInputDialog(null,
"Enter Integer 1",
"Input Dialog",
JOptionPane.QUESTION_MESSAGE);
JOptionPane.showInputDialog(null,
"Enter Integer 2",
"Input Dialog",
JOptionPane.QUESTION_MESSAGE);
JOptionPane.showInputDialog(null,
"Enter Integer 3",
"Input Dialog",
JOptionPane.QUESTION_MESSAGE);
JOptionPane.showInputDialog(null,
"Enter Integer 4",
"Input Dialog",
JOptionPane.QUESTION_MESSAGE);
JOptionPane.showInputDialog(null,
"Enter Integer 5",
"Input Dialog",
JOptionPane.QUESTION_MESSAGE);
// Convert string to int
int intValue = Integer.parseInt(intString);
//Obtain Sum
sum = "int 1" + "int 2" + "int 3" + "int 4" + "int 5";
JOptionPane.showMessageDialog(null,
"Sum"
JOptionPane.INFORMATION_MESSAGE);
}
}
one way to do what you need is declare some variables for your different
ints. Also, sum is not declared in your program and yet you try and set it, you can't set what doesn't exist! When computing your sum, do not compute Strings - this is math, remember? compute integers.
