// compute travel time by highway vs. city streets import java.util.Scanner; public class TravelTime { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("Enter distance in miles: "); double distance = in.nextDouble(); double highway_time = distance / 40.0 * 60; System.out.println("Time to travel by highway: " + highway_time + " minutes"); System.out.print("Enter city street distance in miles: "); distance = in.nextDouble(); double city_time = distance / 15.0 * 60; System.out.println("Time to travel by city streets: " + city_time + " minutes"); if ( highway_time + 5 < city_time ) // the savings has to be greater than 5 minutes to take the highway System.out.println("We recommend taking the highway."); else System.out.println("We recommend taking the city streets."); } }