Skip to content

Instantly share code, notes, and snippets.

@NikolayShaliavski
Created March 19, 2016 10:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NikolayShaliavski/fd25e962ab9dd6911738 to your computer and use it in GitHub Desktop.
Save NikolayShaliavski/fd25e962ab9dd6911738 to your computer and use it in GitHub Desktop.
CalculateExpressions
import java.util.Scanner;
public class CalculateExpressions {
public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
double first = scn.nextDouble();
double second = scn.nextDouble();
double third = scn.nextDouble();
double formulae1 = ((Math.pow(first, 2) + Math.pow(second, 2)) / (Math.pow(first, 2) - Math.pow(second, 2)));
double pow1 = (first + second + third) / Math.sqrt(third);
double result1 = Math.pow(formulae1, pow1);
double formulae2 = (Math.pow(first, 2) + Math.pow(second, 2) - Math.pow(third, 3));
double pow2 = first - second;
double result2 = Math.pow(formulae2, pow2);
double average1 = (first + second + third) / 3;
double average2 = (result1 + result2) / 2;
double diff = Math.abs(average1 - average2);
System.out.printf("F1 result: %.2f; F2 result: %.2f; Diff: %.2f", result1, result2, diff);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment