Java tutorial
//package com.java2s; public class Main { public static float per(String string, String string2) { try { float retail = Float.valueOf(string); float tariff = Float.valueOf(string2); float result = (((tariff - retail) / tariff) * 100); // Margin = ((T-R)/ T)*100% return Math.round(result * 100) / 100f; } catch (Exception e) { } return 0; } }