I need to display the sum and the average without initializing num and num2. I can't figure it out and it's killing me. I can't seem to get the sum or average displayed without assigning the varables values. Any help?
--------------------------------------------------
[CODE=java]import java.io.*;
import javax.swing.*;
class Numbert
{public static void main (String[] args) throws IOException
{ String inData;
int num,num2;
int sum;
int avg;
inData = JOptionPane.sho wInputDialog (null, "Enter an Integer Value. NOW!") ;
num = Integer.parseIn t ( inData); // convert inData to int
inData = JOptionPane.sho wInputDialog (null, "Enter another Integer Value. Ugh..");
num2 = Integer.parseIn t ( inData);
System.out.prin tln ("Sum of both numbers:" +sum);
System.out.prin tln ("The average is:" +avg);
System.out.prin tln ("Good-bye for now, suckahfish!"); //always executed
}
}[/CODE]
--------------------------------------------------
[CODE=java]import java.io.*;
import javax.swing.*;
class Numbert
{public static void main (String[] args) throws IOException
{ String inData;
int num,num2;
int sum;
int avg;
inData = JOptionPane.sho wInputDialog (null, "Enter an Integer Value. NOW!") ;
num = Integer.parseIn t ( inData); // convert inData to int
inData = JOptionPane.sho wInputDialog (null, "Enter another Integer Value. Ugh..");
num2 = Integer.parseIn t ( inData);
System.out.prin tln ("Sum of both numbers:" +sum);
System.out.prin tln ("The average is:" +avg);
System.out.prin tln ("Good-bye for now, suckahfish!"); //always executed
}
}[/CODE]
Comment