Java Array Sum sumandsub(String[] X)

Here you can find the source of sumandsub(String[] X)

Description

sumandsub

License

Apache License

Declaration

static public String sumandsub(String[] X) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    static public String sumandsub(String[] X) {
        double x = 0;
        double y = 0;
        for (int i = 0; i < X.length; i++) {
            if (X[i].startsWith("-"))
                x += Double.valueOf(X[i]);
            /*x+=Double.parseDouble(X[i]);*/
            else//  w w w  . ja  va2  s  .c o m
                y += Double.valueOf(X[i]);
            /*y+=Double.parseDouble(X[i]);*/
        }

        double z = x + y;
        String pop = Double.toString(z);
        return pop;
    }
}

Related

  1. sum(short[] ary)
  2. sum(String[] tokens, int start, int length, String separator)
  3. sum3(double[] a, double[] b)
  4. sum_configurations(int[] elements, int sum)
  5. sumabs(double[] in)
  6. sumArray(double inputArray[])
  7. sumArray(double[] array)
  8. sumArray(double[] array)
  9. sumArray(int Array[])