Calculate Expression using double
import java.util.Locale; import java.util.Scanner; public class Main { public static void main(String[] args) { Locale.setDefault(Locale.ROOT); double numbA = 1.2; double numbB = 2.3; double numbC = 3.4; double f1 = Math.pow((Math.pow(numbA, 2) + Math.pow(numbB, 2)) / (Math.pow(numbA, 2) - Math.pow(numbB, 2)), ((numbA + numbB + numbC) / Math.sqrt(numbC))); double f2 = Math.pow((Math.pow(numbA, 2) + Math.pow(numbB, 2) - Math.pow(numbC, 3)), (numbA - numbB)); double diff = Math.abs((((numbA + numbB + numbC) / 3) - ((f1 + f2) / 2))); System.out.printf("F1 result: %.2f; F2 result: %.2f; Diff: %.2f", f1, f2, diff); }/*www . j ava 2 s. c om*/ }