Results 1 to 3 of 3
- 03-06-2011, 05:33 PM #1
Member
- Join Date
- Feb 2011
- Posts
- 32
- Rep Power
- 0
I cant get this Message dialog to appear.
import javax.swing.JOptionPane;
public class calculateMeanAndSD {
static double marks;
static double mean;
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
for ( int counter = 0; counter < 10; counter++ ) {
marks = Double.parseDouble(JOptionPane.showInputDialog("En ter marks to compute Mean and Standard Deviation: "));
calculateMean();
}
}
public static void calculateMean() {
double sum = 0;
int j = 0;
sum += marks;
mean = sum / 10;
j++;
if (j == 10) {
JOptionPane.showMessageDialog(null, "The Mean of the marks entered is: "+mean);
} else {
System.out.print("");
}
}
}
=========================================
I cannot get this : " JOptionPane.showMessageDialog(null, "The Mean of the marks entered is: "+mean) " to appear.
much help would be appreciated. thanks
- 03-06-2011, 05:38 PM #2
Member
- Join Date
- Feb 2011
- Posts
- 19
- Rep Power
- 0
it will appear only if j's value is 10
- 03-07-2011, 10:03 AM #3
Member
- Join Date
- Mar 2011
- Posts
- 26
- Rep Power
- 0
I am very very new to java but I would try:
and printing j in the else clause to see what it's value is..Java Code:if(j.equals(10))
Other than that, I don't see how the value of j would ever be greater than 1 since every time you call calculateMean() you initiate it with 0 value... That being said, I would try passing "counter" as an argument to calculateMean()Java Code:else { System.out.print(j); }
PS: I am in the "Hello World" stage but I waned to see if I can make anything out of java code... I hope either that I helped you a bit or at least I didn't get on your nerves...
Cheers!Last edited by Stamoulohta; 03-07-2011 at 10:07 AM. Reason: New Idea
Similar Threads
-
show Message Dialog
By akritc in forum AWT / SwingReplies: 7Last Post: 06-10-2010, 02:49 PM -
java message box, how to not show multiple message box with same title or content
By oohay in forum AWT / SwingReplies: 6Last Post: 06-04-2010, 08:43 PM -
How to display array integer in JOptionPane message dialog ?
By Reero8532 in forum New To JavaReplies: 13Last Post: 03-20-2010, 01:03 AM -
Example of SWT Dialog
By Java Tip in forum Java TipReplies: 0Last Post: 01-09-2008, 12:01 PM -
JOptionPane - message dialog
By Java Tip in forum Java TipReplies: 0Last Post: 12-17-2007, 09:11 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks