Help incorporating a Joption Pane
Hello, I'm trying to get the final product of this single code to have the inputs/outputs displayed with a JOption Pane. I'm unfamiliar with how to write and incorporate a separate getData class and wondering if someone could show me?
This class accepts values until a negative value is entered and then averages without said negative value
Code :
import javax.swing.JOptionPane;
import javax.swing.JTextArea;
import javax.swing.JScrollPane;
public class TestWindReadings{
public static void main(String[] args){
int min;
int max;
int count=0;
int sum=0;
Scanner scan=new Scanner(System.in);
System.out.print("Enter wind speed reading ");
System.out.print("Enter wind speed: ");
int cmd=scan.nextInt();
max=cmd;
min=cmd;
sum+=cmd;
count++;
while(cmd>=0){
if(cmd<min){
min=cmd;
}
else if(cmd>max){
max=cmd;
}
sum+=cmd;
count++;
System.out.print("Enter windspeed: ");
cmd=scan.nextInt();
}
if(count>1){
System.out.println("High: " +max);
System.out.println("Low: " +min);
System.out.println("Count: "+ (count-1));
System.out.println("Avg : " +sum/count);
}
}
}
Re: Help incorporating a Joption Pane
Check this out, it has all the information you need:
JOptionPane (Java Platform SE 6)