Guest User

Untitled

a guest
May 20th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 1.33 KB | None | 0 0
  1. package javaapplication9;
  2.  
  3. import java.io.IOException;
  4. import java.util.Scanner;
  5. import static java.lang.Math.*;
  6. import java.text.NumberFormat;
  7. import java.text.ParseException;
  8. import java.util.Locale;
  9.  
  10. public class JavaApplication9 {
  11.  
  12.     public static void main(String[] args) throws IOException, ParseException {
  13.  
  14.         Scanner scanner = new Scanner(System.in);
  15.         NumberFormat f = NumberFormat.getInstance();
  16.         String s = null;
  17.         if(scanner.hasNextLine()){
  18.              s = scanner.nextLine().trim();
  19.         }
  20.         float a = f.parse(s).floatValue();
  21.        
  22.         if(scanner.hasNextLine()){
  23.              s = scanner.nextLine().trim();
  24.         }
  25.         float b = f.parse(s).floatValue();
  26.        
  27.         if(scanner.hasNextLine()){
  28.              s = scanner.nextLine().trim();
  29.         }
  30.         float c = f.parse(s).floatValue();
  31.  
  32.         double f1 = pow(((pow(a,2) + pow(b,2)) / (pow(a,2) - pow(b,2))), ((a + b + c) / sqrt(c)));
  33.         double f2 = pow((pow(a,2) + pow(b,2) - pow(c,3)), (a - b));
  34.         double dif = abs(((a + b + c) / 3) - ((f1 + f2) / 2));
  35.  
  36.         System.out.printf(String.format(Locale.US, "F1 result: %.2f;", f1));
  37.         System.out.printf(String.format(Locale.US, " F2 result: %.2f;", f2));
  38.         System.out.printf(String.format(Locale.US, " Diff:%.2f", dif));
  39.     }
  40. }
Add Comment
Please, Sign In to add comment