// This application works out fuel capacity based on user input of miles per gallon class MilesPerGal { int MilesPer; int Passengers; } class VehicleType { public static void main(String args[]) throws java.io.IOException { MilesPerGal Minivan = new MilesPerGal(); MilesPerGal SportsCar = new MilesPerGal(); MilesPerGal HatchBack = new MilesPerGal(); char choice; do { System.out.println("Car Range Meter"); System.out.println("1. MiniVan"); System.out.println("2. SportsCar"); System.out.println("3. HatchBack"); System.out.print("Please select the vehicle: "); do { choice = (char) System.in.read(); } while(choice == '\n' | choice == '\r'); } while(choice < '1' | choice > '3'); System.out.println(); switch(choice) { case '1': Minivan.MilesPer = 20; Minivan.Passengers = 6; int range1; char FuelCap; do { System.out.print("You have selected MiniVan\n"); System.out.print("Please enter the fuel capacity: "); do { FuelCap = (char) System.in.read(); } while (FuelCap == '1' | FuelCap == '\n' & FuelCap == '\r'); } while (FuelCap < 1 | FuelCap > 1000); range1 = (FuelCap / Minivan.MilesPer); System.out.print("The range of this vehicle is " + FuelCap); break; } } } // assigning vales to SportsCar // SportsCar.FuelCap = System.in.read(); // SportsCar.MilesPer = 25; // SportsCar.Passengers = 2; // assign values to HatchBack // HatchBack.FuelCap = System.in.read(); // HatchBack.MilesPer = 35; // HatchBack.Passengers = 4;