Advertisement
sergAccount

Untitled

Oct 11th, 2020
1,953
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.22 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 appdz3;
  7.  
  8. public class AppDz3 {    
  9.     /*
  10.     Дома
  11.     1) Создать метод который находит
  12.     наибольшее (максимальное) значение из двух целых чисел -
  13.     значений типа int.
  14.     Метод должен возвращать значение типа int
  15.     Проверить данный метод - вызвать его в методе main.
  16.     */
  17.     public static int max(int a, int b){
  18.         if(a>b){
  19.             return a;
  20.         }
  21.         return b;
  22.     }
  23.     /*
  24.     2) Создать метод который находит
  25.     наибольшее (максимальное) значение из трех целых чисел -
  26.     значений типа int.
  27.     Метод должен возвращать значение типа int
  28.  
  29.     Проверить данный метод - вызвать его в методе main.
  30.     */
  31.     public static int max3(int a, int b, int c){
  32.         return max(max(a, b), c);
  33.     }
  34.     /*
  35.     3) Создать метод, который выполняет сложение четырех строк -
  36.     переменных типа String (четырех параметров метода).
  37.     Метод должен возвращать значение типа String.
  38.     Название (имя) метода: concat2
  39.     */
  40.     public static String concat2(String s1, String s2, String s3, String s4){
  41.         //String result = s1 + s2 + s3 + s4;
  42.         //return result;
  43.         return s1 + s2 + s3 + s4;
  44.     }
  45.    
  46.     public static void main(String[] args) {
  47.         // TODO code application logic here
  48.         int result = max(20, 10);
  49.         System.out.println("result=" + result);
  50.        
  51.         int value1 = 20;
  52.         int result2 = max3(value1, 60, 10);
  53.         System.out.println("result2=" + result2);
  54.        
  55.         String str = concat2("HELLO", " JAVA ", "!", "!");
  56.         System.out.println("str=" + str);
  57.     }    
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement