Spicke

Java #1

Oct 10th, 2017
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.43 KB | None | 0 0
  1. //HelloWorld
  2. public class HelloWorld {
  3.     public static void main(String[] args){
  4.         System.out.println("Hello, World!");
  5.     }
  6. }
  7. //чет считаем
  8. import java.util.Scanner;
  9. public class index {
  10.  
  11.     public static void main(String[] args) {
  12.        
  13.         Scanner in = new Scanner(System.in);
  14.         System.out.println("Введите 1 число");
  15.         int a = in.nextInt();
  16.         System.out.println("Введите 2 число");
  17.         int b = in.nextInt();
  18.         System.out.println("Сумма a и b: " + (a+b));
  19.         System.out.println("Разность a и b: " + (a-b));
  20.         System.out.println("Произведение a и b: " + (a*b));
  21.         System.out.println(b!=0 ? ("Частное: " + a/b) : ("Кто на ноль делит?"));
  22.         in.close();
  23.     }
  24. }
  25. ///
  26. import java.util.Scanner;
  27.  
  28.  
  29. public class tatata {
  30.  
  31.     public static void main(String[] args) {
  32.         Scanner in = new Scanner(System.in);
  33.         System.out.println("Введите a");
  34.         double a = in.nextDouble();
  35.         System.out.println("Введите b");
  36.         double b = in.nextDouble();
  37.         System.out.println("Введите c");
  38.         double c = in.nextDouble();
  39.         double p = ((a+b+c)/2);
  40.         double s = (Math.sqrt(p*(p-a)*(p-b)*(p-c)));
  41.         System.out.println(((a+b>c) && (a+c>b) && (b+c)>a) ? ("Площадь треугольника = " + s) : ("Треугольника с данными сторонами не существует!"));
  42.         in.close();
  43.     }
  44. }
  45.  
  46. ////
  47. import java.util.Scanner;
  48. public class opaopa {
  49.     public static void main(String[] args) {
  50.         Scanner in = new Scanner(System.in);
  51.         System.out.println("Введите число");
  52.         int a = in.nextInt();
  53.         int max = 0, min = 9;
  54.         while (a > 0){
  55.             if(a % 10 < min)
  56.                 min = a%10;
  57.             if(a % 10 > max)
  58.                 max = a%10;
  59.             a = (int) Math.floor(a/10);
  60.         }
  61.         System.out.println("Наименьшая цифра: " + min);
  62.         System.out.println("Наибольшая цифра: " + max);
  63.         in.close();
  64.     }
  65. }
  66. //пароль
  67. import java.util.Scanner;
  68.  
  69.  
  70. public class yes {
  71.  
  72.     public static void main(String[] args) {
  73.         Scanner in = new Scanner(System.in);
  74.         System.out.println("Введите пароль");
  75.         String a = in.nextLine();
  76.         System.out.println("Введите пароль ещё раз");
  77.         String b = in.nextLine();
  78.         boolean c = a.equals(b);
  79.         System.out.println( c ? ("Пароль введен верно!") : ("Проверьте правильность ввода пароля!") );
  80.         in.close();
  81.     }
  82.  
  83. }
Add Comment
Please, Sign In to add comment