Can anyone help me. I have been bangin my head on this one for two days. variable number may not have been initialized. code to enter single digit number and return largest of ten. code is as follows.
// Java packages
import javax.swing.JOptionPane;
public class Counter {
// main method begins execution of Java application
public static void main( String args[] )
{
// declare variables
int counter; // loop counter
String number; // number entered by user
double number2 = 0; // number converted to integer
double largest = 0; // largest of all numbers entered
for( counter = 0; counter < 10; counter++ )
number = JOptionPane.showInputDialog( "Enter a single digit number: ");
number2 = Double.parseDouble( number );
if ( number2 > number2)
largest = number2;
JOptionPane.showMessageDialog( null, largest + " is the largest");
}
}