Advertisement
BlastFM

3_1 dowhil

Apr 7th, 2021
400
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.83 KB | None | 0 0
  1. package lab1;
  2.  
  3. import static java.lang.Math.pow;
  4.  
  5. import java.util.Scanner;
  6.  
  7. public class Lab3_1_dowhile {
  8.  
  9.     public static void main(String[] args) {
  10.         double a,e,s1,s2;
  11.         int k = 1, j = 1, L, M;
  12.  
  13.         Scanner input = new Scanner(System.in);
  14.        
  15.         System.out.print("L");
  16.         L = input.nextInt();
  17.        
  18.         System.out.print("M");
  19.         M = input.nextInt();
  20.        
  21.         System.out.print("a");
  22.         a = input.nextDouble();
  23.        
  24.         input.close();
  25.        
  26.         e = 1.0;
  27.         s1 = 0;
  28.         s2 = 0;
  29.        
  30.         do {
  31.             e *= a * (pow(k,2)+1.0);
  32.             s2 += (pow(k,2)/(a+1.0));
  33.             k++;
  34.         }
  35.         while(k<=M);
  36.        
  37.         do {
  38.             s1 += ((j+2.0)/j);
  39.             j++;
  40.         }
  41.         while(j<=L);
  42.        
  43.         System.out.print(e+s1-s2);
  44.  
  45.     }
  46.  
  47. }
  48.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement