Simple For Loop mix up

Joined
Feb 2, 2008
Messages
1
Reaction score
0
I needed to solve a question which asked me to allow ten grades to be entered, and find the average [which means finding the total]

below is what I have so far. An though it compiles without error and runs showing the JOption Pane, it only does so once, when It should appear ten times, what am I doing wrong =[?

could someone guide me please, I'd appreciate it, thank you.

import javax.swing.*;

public class AverageTest{

public static void main(String[]args){

double total=0;

for (int i=1; i<=10; i++);
{
String grade= JOptionPane.showInputDialog("Enter Grade");

double g= Double.parseDouble(grade);

total+=g;
}
double avg;

avg= total/10;

JOptionPane.showMessageDialog(null,"The Average is"+ avg);

}//End class


}//End Main
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,145
Latest member
web3PRAgeency
Top