daily pastebin goal
44%
SHARE
TWEET

Java lab 1

a guest Sep 14th, 2018 55 in 3 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package Lab1;
  2.  
  3. import java.util.Scanner;
  4. import static java.lang.Math.cos;
  5.  
  6. class Lab1 {
  7.     public static void main(String[] args) throws java.lang.Exception {
  8.         double a;
  9.         double z1, z2;
  10.         Scanner scanner = new Scanner(System.in);
  11.  
  12.         while(scanner.hasNextDouble) {
  13.             a = scanner.nextDouble();
  14.  
  15.             z1 = cos(a) + cos(2*a) + cos(6*a) + cos(7*a);
  16.             z2 = 4 * cos(a/2) * cos(5*a/2) * cos(4*a);
  17.  
  18.             System.format("cos(%f) + cos(2*%f) + cos(6*%f) + cos(7*%f) =\n4 * cos(%f/2) * cos(5*%f/2) * cos(4*%f)\n",
  19.                           a,a,a,a,a,a,a);
  20.             System.format("%f = %f\n\n", z1, z2);
  21.         }
  22.     }
  23. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top