/*	James Little wednesday 7th March 2001	Lines and points*/package jlittle_ex1;import basicIO.*;import java.text.*;public class Line {		// datafields, type long for big calculations.	private long [] xPoint;	private long [] yPoint;	private long [] hypotenuse;	// s is the number of segments in the line.	private int s;		// line constructor accepts segments, line number and x, y arrays	public Line(int segs, int a, long [] x, long [] y) {		// segs is the number of segments in this line.. can be anything		s=segs;		// allocate array to array		xPoint = x;		yPoint = y;		// might as well print the line number here :)		Out.println("Line "+a);			}			// method think works out the distance of all segments and lines... also prints them	public void think() {			// local variables		double distance=0;			// length of one segment		double totalHyp=0;			// takes value of shortest distance 		double totalDist=0;			// adds segment lengths		DecimalFormat df = new DecimalFormat("0.0");		// for deciaml formatting				// this loop calculates the segment length and prints it out		// also calculates the total distance of the segments		for(int i=0; i<s; i++){			distance=(Math.sqrt((xPoint[i+1]-xPoint[i])*(xPoint[i+1]-xPoint[i])+(yPoint[i+1]-yPoint[i])*(yPoint[i+1]-yPoint[i])));			Out.println("\tSegment "+(i+1)+" distance "+df.format(distance)+" units");			totalDist+=distance;			}					// prints the total of the line		Out.println("\tTotal distance is: " + df.format(totalDist) + " units");				// long x and y accept the value of any difference between point 1 and point infinity, and square it		long x=(xPoint[xPoint.length-1]-xPoint[0])*(xPoint[xPoint.length-1]-xPoint[0]);		long y=(yPoint[yPoint.length-1]-yPoint[0])*(yPoint[yPoint.length-1]-yPoint[0]);				// total hyp accepts the hypotenuse		totalHyp=Math.sqrt(x+y);				// if the total hypotenuse is only one unit, then i will print a singular version.		if(totalHyp==1.0){			Out.println("\tStart-End shortest distance is: " + df.format(totalHyp) + " unit");		}else Out.println("\tStart-End shortest distance is: " + df.format(totalHyp) + " units");	}			}
-----------------------------8025690684988810411252232219
Content-Disposition: form-data; name="userfile"; filename="LinesAndPoints.java"

/*	James Little wednesday 7th March 2001Lines and points*/package jlittle_ex1;import basicIO.*;public class LinesAndPoints {private static long [] xCoOrdinates, yCoOrdinates;public static void main(String [] args) {   int count = 1;   int sent =0;   int pointNumber = 0;   int temp = 0;   while (In.readLine() != null) {       // set array index       if(In.countTokens()==1){	// entry only valid if there is only one token	   temp=In.getInt();	   if((temp>=2)&&(temp<=19)){	       pointNumber=temp;	   }else{	       System.out.println("Error : Sorry only reasonable input for the \"number of points\" should apply. Program terminated.");	       System.exit(-1);	   }	   // initialize arrays	   xCoOrdinates = new long[pointNumber];	   yCoOrdinates = new long[pointNumber];       }else if(In.countTokens()>1){	   System.out.println("Error : Wrong number of entries for point number. Program terminated.");	   System.exit(-1);       }else{	   System.out.println("Error: invalid input... not enough points.");	   System.exit(-1);       }// end if	                 // read points into  x and y arrays       for(int i=0; i<pointNumber; i++) {	   In.readLine();	   if(In.countTokens()==2){	// entry only valid if two tokens on line	       temp = In.getInt();	       if((temp>=0)&&(temp<=99999)){		   xCoOrdinates[i] = temp;	       }else{		   // terminate program and reason for termination		   System.out.println("Error : Input out of range (0-99999). Program terminated.");		   System.exit(-1);	       }	       temp = In.getInt();	       if((temp>=0)&&(temp<=99999)){		   yCoOrdinates[i] = temp;	       }else {		   // terminate program and reason for termination		   System.out.println("Error : Input out of range (0-99999). Program terminated.");		   System.exit(-1);	       }	   }else{	       // terminate program and reason for termination	       System.out.println("Error : Not enough points. Program terminated.");	       System.exit(-1);	   }       }// end for loop       // send messages       int segments = pointNumber-1;              Line l = new Line(segments, count, xCoOrdinates, yCoOrdinates);       l.think();       // count just keeps track of the line number       count++;   } // end while loop	   System.out.println("END OF OUTPUT");}// end main method		}// end class