Advertisement
blackpab

z2

Feb 27th, 2017
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.38 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package zestaw;
  7. import java.util.Scanner;
  8.  
  9. /**
  10.  *
  11.  * @author student
  12.  */
  13. public class Zestaw {
  14.  
  15.     /**
  16.      * @param args the command line arguments
  17.      */
  18.     public static void main(String[] args) {
  19.         // TODO code application logic here
  20.         Scanner skaner = new Scanner(System.in);
  21.         System.out.println("LiczbaA = ");
  22.             double LiczbaA = skaner.nextDouble();
  23.         System.out.println("LiczbaB = ");
  24.             double LiczbaB = skaner.nextDouble();
  25.            
  26.         double sa = (LiczbaA+LiczbaB)/2;
  27.         double sg = Math.sqrt(LiczbaA * LiczbaB);
  28.         double shOdw = 1/LiczbaA + 1/LiczbaB;
  29.         double sh = 1/shOdw;
  30.        
  31.         System.out.println("arytmetyczna: " + sa + " geometryczna: " + sg + " harmoniczna: " + sh );
  32.        
  33.        
  34.        
  35.        
  36.        
  37.        
  38.        
  39.  
  40.        
  41.     }
  42.     /*
  43.  * To change this license header, choose License Headers in Project Properties.
  44.  * To change this template file, choose Tools | Templates
  45.  * and open the template in the editor.
  46.  */
  47. package zestaw;
  48.  
  49. import java.util.Scanner;
  50.  
  51. /**
  52.  *
  53.  * @author student
  54.  */
  55. public class Zestaw {
  56.  
  57.     /**
  58.      * @param args the command line arguments
  59.      */
  60.     public static void main(String[] args) {
  61.         // TODO code application logic here
  62.         Scanner skaner = new Scanner(System.in);
  63.  
  64.         System.out.print("BokA = ");
  65.         int BokA = skaner.nextInt();
  66.         System.out.print("BokB = ");
  67.         int BokB = skaner.nextInt();
  68.         System.out.print("BokC = ");
  69.         int BokC = skaner.nextInt();
  70.  
  71.         if (BokA + BokB < BokC) {
  72.             System.out.println("Nie mozna zbudowac trojkata");
  73.         } else if (BokB + BokC < BokA) {
  74.             System.out.println("Nie mozna zbudowac trojkata");
  75.         } else if (BokA + BokC < BokB) {
  76.             System.out.println("Nie mozna zbudowac trojkata");
  77.         } else {
  78.             System.out.println("Mozna zbudowac Trojkat");
  79.         }
  80.     }
  81. }
  82. //& - sprawdza wszystkie warunki nawet jesli warunek po lewej przyjmuje false
  83. //&& - jesli warunek po lewej przyjmuje false, warunek po prawej nie jest sprawdzany
  84. //alt + shift + f //Automatyczne formatowanie kodu
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement