View Single Post
  #1 (permalink)  
Old 03-19-2008, 10:45 PM
MrHuggykins MrHuggykins is offline
Member
 
Join Date: Mar 2008
Posts: 1
MrHuggykins is on a distinguished road
I need help fixing my code.. or non code?
import java.io.*;
import javax.swing.*;

class Numbert



{public static void main (String[] args) throws IOException
{ String inData;
int num ,num2;
int sum= num+num2;
int avg= sum/2;

inData = JOptionPane.showInputDialog (null, "Enter an Integer Value.") ;
num = Integer.parseInt ( inData); // convert inData to int

inData = JOptionPane.showInputDialog (null, "Enter another Integer Value.");
num2 = Integer.parseInt ( inData);

System.out.println ("Sum of both numbers:" +sum);
System.out.println ("The average is:" +avg);

System.out.println ("Good-bye for now, suckahfish!"); //always executed
}

}

-----------------
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 need to let the user enter any number they want and get the sum and averages displayed for them. I'm in college and this is the first Java assignment my professor has given us. Any help is appreciated, I really want to get familiar with this language.
Reply With Quote
Sponsored Links