@@ -0,0 +1,1000 @@
+// Add a constructor.%0A%0Aclass Vehicle %7B%0A%09int passengers; // number of passengers%0A%09int fuelcap;    // fuel capacity in gallons%0A%09int mpg;        // fuel consumption in miles per gallon%0A%09%0A%09// This is a constructor for Vehicle.%0A%09Vehicle(int p, int f, int m) %7B%0A%09%09passengers = p;%0A%09%09fuelcap = f;%0A%09%09mpg = m;%0A%09%7D%0A%09%0A%09// Return the range.%0A%09int range() %7B%0A%09%09return mpg * fuelcap;%0A%09%7D%0A%09%0A%09// Compute fuel needed for a given distance.%0A%09double fuelneeded(int miles) %7B%0A%09%09return (double) miles / mpg;%0A%09%7D%0A%7D%0A%0Aclass VehConsDemo %7B%0A%09public static void main(String args%5B%5D) %7B%0A%09%09%0A%09%09// construct complete vehicles%0A%09%09Vehicle minivan = new Vehicle(7, 16, 21);%0A%09%09Vehicle sportscar = new Vehicle(2, 14, 12);%0A%09%09double gallons;%0A%09%09int dist = 252;%0A%09%09%0A%09%09gallons = minivan.fuelneeded(dist);%0A%09%09%0A%09%09System.out.println(%22To go %22 + dist + %22 miles minivan needs %22 + gallons + %22 gallons of fuel.%22);%0A%09%09%0A%09%09gallons = sportscar.fuelneeded(dist);%0A%09%09%0A%09%09System.out.println(%22To go %22 + dist + %22 miles sportscar needs %22 + gallons + %22 gallons of fuel.%22);%0A%09%7D%0A%7D%0A

Add a constructor to Vehicle class