Assignment_6 - The"Assignment_6 class/This program...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
// The "Assignment_6" class. //This program calculates the slope, correlation coefficient and the y intercept //for a series of numbers which is imported from another file import apsc142.*; public class Assignment_6 { public static void main (String [] args) { final int maxval = 1000;//maximum value of numbers double slope = 0; double intercept = 0; double corr = 0; double xy = 0; double x [] = new double [maxval]; double y [] = new double [maxval]; int i = 0;//loop purpose int c = 0;//average purposes int d = 0; FileIn in = new FileIn ("test*.txt"); if (in.readStatus != in.FILE_NOT_FOUND)//checks if while exists { while (in.readStatus != in.EOF) { for (i = 0 ; i < maxval ; i++) { if (in.readStatus == in.EOF||in.readDouble()==-99.99) { break; } else if (i % 2 == 0)//reads first column { x [i / 2] = in.readDouble (); c = c + 1; //System.out.println ("x[" + (i / 2) + "]" + x [i / 2]); } else if (i % 2 == 1)//reads second colum { d = d + 1; y [i - d] = in.readDouble (); System.out.println ("*y[" + (i - d) + "]:" + y [i - d]);
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/01/2010 for the course APPLIED SC 142 taught by Professor Professorstansimmons during the Winter '10 term at Queens University.

Page1 / 2

Assignment_6 - The"Assignment_6 class/This program...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online