public void getRate() { RouteId id = new RouteId(); HubEntity hub = hubsRegistry.findHubByName(selectedHub); CoefficientsInfo coef = hubsRegistry.getCoefficientsForHub(selectedHub); id.setDestName(Parser.getCity(destination)); id.setDestState(Parser.getState(destination)); id.setHubName(hub.getCity()); id.setHubState(hub.getState()); RouteEntity route = repo.findRoute(id); if (route == null) { try { route = GoogleHandler.createRouteEntity( id.getHubName(), id.getHubState(), id.getDestName(), id.getDestState()); route = repo.saveRoute(route, id); } catch (GoogleServiceParamException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (GoogleServiceException e) { // TODO Auto-generated catch block e.printStackTrace(); } } float interceptX = coef.getIntercept().getX(); float rate = 0; if (route.getDistanceInMiles() < interceptX) { rate = route.getDistanceInMiles() * coef.getCoef1().getBeta() + coef.getCoef1().getAlpha(); } else { rate = route.getDistanceInMiles() * coef.getCoef2().getBeta() + coef.getCoef2().getAlpha(); } Messanger.show( "Got rate ", route.getDestName() + " : " + route.getDistanceInMiles() + "mi, rate: " + rate); }