MileageCalculator

# MileageCalculator - /BufferedWriter out = new...

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

package lab07; p import java.io.BufferedWriter; import java.io.File; import java.io.FileNotFoundException; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; 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");
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

{[ snackBarMessage ]}

Ask a homework question - tutors are online