MileageCalculator - /BufferedWriter out = new...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
package lab07; p import; import; import; import; import; import; import java.util.Scanner; i public class MileageCalculator { public static void main(String[] args) throws IOException { File file = new File("C:\\Users\\Aldin's Laptop W7\\Desktop\\Coms 227 Files\\Mileage.txt"); PrintWriter two = new PrintWriter("C:\\Users\\Aldin's Laptop W7\\Desktop\\Coms 227 Files\\output.txt");
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: //BufferedWriter out = new BufferedWriter(two); Scanner one = new Scanner(file); int size = one.nextInt(); float col1 = new float[size]; float col2 = new float[size]; //String three = new String[size]; int counter = 0; while(one.hasNextFloat()){ col1[counter] = one.nextFloat(); col2[counter] = one.nextFloat(); counter++; } for(int i = 1; i < col1.length; i++){ two.println(("Mileage " + i + " : "+ (col1[i] - col1[i-1])/col2[i])); } two.close(); } }...
View Full Document

This note was uploaded on 09/20/2011 for the course COM SCI 227 taught by Professor Staff during the Spring '11 term at Iowa State.

Ask a homework question - tutors are online