Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {

    public static int calculateAccuracy(int txPower, double rssi) {
        if (rssi == 0) {
            return -100; // if we cannot determine accuracy, return -1.
        }
        double ratio = rssi * 1.0 / txPower;
        if (ratio < 1.0) {
            return (int) (100 * Math.pow(ratio, 10));
        } else {
            double accuracy = (0.89976) * Math.pow(ratio, 7.7095) + 0.111;
            return (int) (100 * accuracy);
        }
    }
}