我不熟悉Java编程。我有一个项目应该汇总一系列输入,并计算这些数字的平均值。现在,无论我为价值投入了什么,道达尔都会达到零。我卡住了。请帮忙。谢谢。
private class InputButtonListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
for(int i=0; i<7; i++)
{
numInput = 0.0;
strInput = JOptionPane.showInputDialog(null, "How many hours did you sleep on day " + (i+1));
numInput = Double.parseDouble(strInput);
numInput +=total;
}
}
}
private class CalcButtonListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
JOptionPane.showMessageDialog(null,"The total amount of sleep for the week is " + total + " hours");
JOptionPane.showMessageDialog(null,"The average amount of sleep for 7 days is " + avg + " hours");
}
}
public static void main(String[] args)
{
HoursSlept HS = new HoursSlept();
}}