Java tutorial
//package com.java2s; public class Main { public static int getUPSRuntime(float totalWatts, int vah, int ptare, float bCurve_scale, float bCurve_expo, float bCurve_rSlope, float bCurve_comp, int max_runtime) { if ((vah <= 0) || (totalWatts < 0) || (ptare < 0) || (totalWatts + ptare == 0) || (bCurve_scale <= 0) || (bCurve_expo <= 0) || (bCurve_rSlope < 0)) { return 0; } else { return (int) Math.round(60 * bCurve_scale * (Math.pow(vah / (totalWatts + ptare), bCurve_expo) - bCurve_rSlope + bCurve_comp * (totalWatts + ptare) / vah)); } } }