2
28/10/2024 7:22 pm
Topic starter
Write a program that reads three floating point numbers from the console and calculates their result with the following formula:
Then calculate the difference between the average of the three numbers and the average of the two formula.
Average (a, b, c) – Average (f1, f2);
The results must look like this:
1 Answer
2
28/10/2024 7:23 pm
Interesting task! Here is my solution to it:
import java.util.Scanner; public class CalculateExpression { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); double a = scanner.nextDouble(); double b = scanner.nextDouble(); double c = scanner.nextDouble(); double firstResult = Math.pow(((a * a + b * b) / (a * a - b * b)), (a + b + c) / Math.sqrt(c)); double secondResult = Math.pow((a * a + b * b - c * c * c), a - b); double average = ((firstResult + secondResult) / 2) - ((a + b + c) / 3); System.out.println(average); } }