import java.io.*;
import java.math.*;
import java.util.Arrays;
public class NewStatJFrame extends javax.swing.JFrame {
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
int numarr[]=new int[9000];
int count=0;
Mean Men = new Mean();
try {
DataInputStream in = new DataInputStream(new FileInputStream("c:\\tc\\num.txt"));
String num = in.readLine();
while (num != null){
numarr[count]=Integer.parseInt(num);
num = in.readLine();
count++;
}
in.close();
jTextField1.setText(Men.mean(numarr, count-1));
} catch (Exception e) {System.out.println("Sorry, it cannot be done!");}
for (int i=0;i<=count-1;i++)
{System.out.println(numarr[i]);}
}
calculate mean,mode,median,rangeread numbers from a file and then do the calculations
Page 1 of 1
1 Replies - 14077 Views - Last Post: 10 April 2008 - 04:53 PM
#1
calculate mean,mode,median,range
Posted 10 April 2008 - 04:41 PM
design an interface, read a set of values from a file, write methods to calculate the following:mean, mode, median, range.
Replies To: calculate mean,mode,median,range
#2
Re: calculate mean,mode,median,range
Posted 10 April 2008 - 04:53 PM
So what is your question ?
You have problem with the calculations or the GUI ?
Just a suggestion (not forced to follow it): start by a console application that will do all the calculations and print them with System.out.println() when that part works then you it will be time to start coding a nice display with Swing.
Divide to reign the Romans used to say.
You have problem with the calculations or the GUI ?
Just a suggestion (not forced to follow it): start by a console application that will do all the calculations and print them with System.out.println() when that part works then you it will be time to start coding a nice display with Swing.
Divide to reign the Romans used to say.
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote




|