Example usage for java.lang Double parseDouble

List of usage examples for java.lang Double parseDouble

Introduction

In this page you can find the example usage for java.lang Double parseDouble.

Prototype

public static double parseDouble(String s) throws NumberFormatException 

Source Link

Document

Returns a new double initialized to the value represented by the specified String , as performed by the valueOf method of class Double .

Usage

From source file:com.tsg.sitemapwebappmvc.controller.FlooringCalcController.java

@RequestMapping(value = "/FlooringCalcController", method = RequestMethod.POST)
public String getFlooringCalcResults(HttpServletRequest request, Model model) {

    String newWidth = request.getParameter("width");
    Double width = Double.parseDouble(newWidth);
    String newLength = request.getParameter("length");
    Double length = Double.parseDouble(newLength);
    String newCost = request.getParameter("costSqFt");
    Double costPerSqFt = Double.parseDouble(newCost);

    FlooringCalculator floorCalc = new FlooringCalculator(width, length, costPerSqFt);

    double newArea = floorCalc.getArea(width, length);
    double newMatCost = floorCalc.getMateialCost(newArea, costPerSqFt);
    double newLaborCost = floorCalc.getLaborRate();
    double newTotal = floorCalc.getOrderTotal(newLaborCost, newMatCost);
    double totalTime = newArea / 20;

    request.setAttribute("newMatCost", newMatCost);
    request.setAttribute("newLaborCost", newLaborCost);
    request.setAttribute("newArea", newArea);
    request.setAttribute("newTotal", newTotal);
    request.setAttribute("totalTime", totalTime);

    return "fcresponse";
}

From source file:com.opengamma.financial.analytics.PositionWeightFromNAVFunction.java

public PositionWeightFromNAVFunction(final String nav) {
    Validate.notNull(nav, "nav");
    _nav = Double.parseDouble(nav);
}

From source file:com.dianping.simple.spring.CarFactroyBean.java

@Override
public Object getObject() throws Exception {
    // TODO Auto-generated method stub
    Car car = new Car();
    String[] infos = StringUtils.split(carInfo, ",");
    car.setBrand(infos[0]);//  www  .  j  a  va  2s. c om
    car.setMaxSpeed(Integer.parseInt(infos[1]));
    car.setPrice(Double.parseDouble(infos[2]));
    return car;
}

From source file:pdfboxtest.HistandVolChart.java

public File chart(String ticker, int numberOfYears) throws Exception {
    BufferedReader reader = null;
    String splitBy = ",";
    String line;//  www . ja  v a2s  .c o m
    double stockPrice;
    File file = new File(
            "C:\\Users\\Matthew\\Documents\\NetBeansProjects\\TradingData\\ticker\\" + ticker + ".data");
    reader = new BufferedReader(new FileReader(file));

    DefaultCategoryDataset stockDataSet = new DefaultCategoryDataset();
    while (reader.readLine() != null) {
        line = reader.readLine();
        String[] stockData = line.split(splitBy);
        stockPrice = Double.parseDouble(stockData[0]);
        stockDataSet.addValue(stockPrice, ticker, line);
    }

    JFreeChart chartObject = ChartFactory.createLineChart(null, null, null, stockDataSet,
            PlotOrientation.VERTICAL, false, false, false);
    int width = 300;
    int height = 200;
    File chart = new File("C:\\Users\\Matthew\\Documents\\NetBeansProjects\\PDFBoxTest\\" + ticker + ".jpg");
    ChartUtilities.saveChartAsJPEG(chart, chartObject, width, height);
    return chart;
}

From source file:com.swcguild.springmvcwebapp.controller.TipCalcController.java

@RequestMapping(value = "/tipCalc", method = RequestMethod.POST)
public String calculateTip(HttpServletRequest request, Model model) {

    try {//  w ww .ja v  a 2 s .co m
        originalAmount = Double.parseDouble(request.getParameter("originalAmount"));
        tipPercentage = Double.parseDouble(request.getParameter("tipPercentage"));

        tipAmount = (tipPercentage * originalAmount) / 100;
        finalAmount = originalAmount + tipAmount;

        DecimalFormat df = new DecimalFormat("#.00");

        model.addAttribute("originalAmount", df.format(originalAmount));
        model.addAttribute("tipAmount", df.format(tipAmount));
        model.addAttribute("tipPercentage", tipPercentage);
        model.addAttribute("finalAmount", df.format(finalAmount));
    } catch (NumberFormatException e) {
    }

    return "tipCalcResponse";
}

From source file:biblioteca.reportes.ChartCreator.java

public static DefaultCategoryDataset asignarBarDataset(ArrayList<String> Valores) {
    DefaultCategoryDataset dataSet = new DefaultCategoryDataset();
    int size = Valores.size();
    size = (size <= 32) ? size : 32;//from  w  w  w .j  av  a2 s . c  o m
    for (int i = 2; i < size; i += 2) {
        dataSet.setValue(Double.parseDouble(Valores.get(i + 1)), "Grafica", Valores.get(i));
    }
    return dataSet;
}

From source file:at.bestsolution.efxclipse.tooling.rrobot.impl.RRobotImpl.java

private static Object getVariableData(Variable v) {
    switch (v.getType()) {
    case BOOLEAN:
        return Boolean.parseBoolean(v.getDefaultValue());
    case DOUBLE:/*from  ww w.j a  va  2s .  com*/
        return Double.parseDouble(v.getDefaultValue());
    case INT:
        return Integer.parseInt(v.getDefaultValue());
    default:
        return v.getDefaultValue();
    }
}

From source file:edu.scripps.fl.hibernate.DoubleListStringType.java

public List<Double> getListFromString(String list) {
    String strs[] = list.split("\r?\n");
    List<Double> ids = newList(strs.length);
    for (int ii = 0; ii < strs.length; ii++) {
        if (null != strs[ii] && !strs[ii].equals("")) {
            Double dbl = Double.parseDouble(strs[ii]);
            ids.set(ii, dbl);//w  w w  . ja  v  a  2s  .c o m
        }
    }
    return ids;
}

From source file:ch.ksfx.util.calc.MovingAverageCalculator.java

public static Double calculateMovingAverageObservation(List<Observation> assetPrices, boolean askPrice) {
    Double assetPricesSum = 0.0;/*from  w w w.j a va  2 s . c o m*/

    if (askPrice) {
        for (Observation ap : assetPrices) {
            assetPricesSum += Double.parseDouble(ap.getScalarValue());
        }
    } else {
        for (Observation ap : assetPrices) {
            assetPricesSum += Double.parseDouble(ap.getScalarValue());
        }
    }

    return assetPricesSum / assetPrices.size();
}

From source file:Main.java

/**
 * Same as {@link #asDouble(String, Node)} but allows an xpath to be passed
 * in explicitly for reuse.//ww  w  .  j  a  v a 2 s  .  c  o  m
 */
public static Double asDouble(String expression, Node node, XPath xpath) throws XPathExpressionException {
    String doubleString = evaluateAsString(expression, node, xpath);
    return (isEmptyString(doubleString)) ? null : Double.parseDouble(doubleString);
}