Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    public static float bracketFloat(float value, float lower, float upper) {
        if (upper < lower)
            return 0f;
        if (value > upper)
            return upper;
        if (value < lower)
            return lower;
        return value;
    }

    public static float bracketFloat(String str, float floor, float ceiling) throws NumberFormatException {
        float val = 0f;
        try {
            val = Float.parseFloat(str);
        } catch (NumberFormatException e) {
            e.printStackTrace();
        }
        val = bracketFloat(val, floor, ceiling);
        return val;
    }
}