Skip to content

Instantly share code, notes, and snippets.

@bytecodeman bytecodeman/ Secret
Last active Sep 13, 2018

What would you like to do?
CSC-111 Miles per Gallon program
import java.util.Scanner;
public class MilesPerGallon {
public static void main(String[] args) {
Scanner input = new Scanner(;
System.out.print("Initial Odometer: ");
double initOdometer = input.nextDouble();
System.out.print("Final Odometer: ");
double finalOdometer = input.nextDouble();
System.out.print("Number of Gallons: ");
double gallons = input.nextDouble();
double mpg = (finalOdometer - initOdometer) / gallons;
System.out.printf("MPG = %f\n", mpg);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.