//******************************************************************** // GasMileage.java Author: Lewis/Loftus, modified by Barland. // // Demonstrates the use of the Scanner class to read numeric data. //******************************************************************** class GasMileage { //----------------------------------------------------------------- // Ask the user for their gas-usage info (interactively from terminal), // and return the mileage. //----------------------------------------------------------------- double calcMileageInteractively() { // Create an input-scanner, and name it 'scan': java.util.Scanner scan = new java.util.Scanner( System.in ); System.out.print( "Enter the number of miles: " ); // Get the next double, and name that result 'miles', for future use. double miles = scan.nextDouble(); System.out.print( "Enter the gallons of fuel used: " ); // Get the next double, and name that result 'gallons', for future use. double gallons = scan.nextDouble(); return miles/gallons; } }