Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Your tasks are The calculation is just: So, to calculate the mileage between the

ID: 3532278 • Letter: Y

Question

Your tasks are

The calculation is just:

So, to calculate the mileage between the first two fuelings, we have (91538 - 91183) / 11.007 = ~32.234. Note that we cannot calculate mileage if we do not have a previous odometer reading available, so the gallons in the first line is not used. Your mileage values should look something like:

Write your code in a class named MileageCalculator. Do step 1 in a static helper method that returns the constructed ArrayList, and do the rest in the mainmethod using that list.

Explanation / Answer

public class MileageCalculator{ public List mileagelist=new ArrayList(); public List petrollist=new ArrayList(); public List kilometreslist=new ArrayList(); public void read(String filename){ BufferedReader br = new BufferedReader(new FileReader(filename)); try { StringBuilder sb = new StringBuilder(); String line = br.readLine(); while (line != null) { sb.append(line); sb.append(" "); line = br.readLine(); myindex=0; for(int i=0;i