All Downloads are FREE. Search and download functionalities are using the official Maven repository.

be.webtechie.resistorcalculator.util.CalculateTotal Maven / Gradle / Ivy

There is a newer version: 0.1.4
Show newest version
package be.webtechie.resistorcalculator.util;

import java.util.List;

/**
 * Calculates the total value for a list of resistor values.
 */
public class CalculateTotal {

    /**
     * Calculate the total for a list of serial resistors.
     *
     * @param values {@link List} of {@link Double} values
     * @return The calculate total value
     */
    public static double serial(List values) {
        return values.stream().reduce(0D, (a, b) -> a + b);
    }

    /**
     * Calculate the total for a list of parallel resistors.
     *
     * @param values {@link List} of {@link Double} values
     * @return The calculate total value
     */
    public static double parallel(List values) {
        return 1 / values.stream().reduce(0D, (a, b) -> a + (1/b));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy