Question
Miles per gallon (MPG) calculation. Given a file containing data about the miles driven and the gallons of gas used per trip, write a Java
Miles per gallon (MPG) calculation. Given a file containing data about the miles driven and the gallons of gas used per trip, write a Java program that calculates the MPG per trip and overall MPG. Sample input file as below: 350 12.3 200 10.1 500 18.7
Each line contains the miles driven and gallons used for a single trip. The input file name must be given through the first command line argument args[0]. The output for the above input should look like below:
Trip 1: 28.5 Trip 2: 19.8 Trip 3: 26.7 Overall: 25.5
The output has to be written into a file. The output file name is given through the second command line arguments args[1].
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started