Skip to content

Instantly share code, notes, and snippets.

@imryan
Created October 9, 2013 17:20
Show Gist options
  • Save imryan/6904887 to your computer and use it in GitHub Desktop.
Save imryan/6904887 to your computer and use it in GitHub Desktop.
Stupid mileage program.
import java.util.Scanner;
public class Mileage {
public static void main(String[] args) {
// Declare variables
Scanner sc = new Scanner(System.in);
double miles;
double gallons;
double mileage;
// Get input
miles = sc.nextDouble();
gallons = sc.nextDouble();
// Calculate mileage
mileage = (miles / gallons);
// Output result
System.out.println("\nYour mileage is: " + mileage + " for " + miles + " miles.");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment