Learn Java - Exercise 02x - Passing Parameters to a Method & Returning Values

แชร์
ฝัง
  • เผยแพร่เมื่อ 20 ม.ค. 2025

ความคิดเห็น • 15

  • @NgolaNalane
    @NgolaNalane 5 ปีที่แล้ว +21

    This channel is severely underrated. This man is doing God's work

    • @miguelbahena2603
      @miguelbahena2603 3 ปีที่แล้ว +2

      no cap, he deserves more recognition

  • @katelynbradley9436
    @katelynbradley9436 2 ปีที่แล้ว +1

    I agree this channel is so underrated!! Methods literally have brought me to tears and 1 video with this guy and it all makes sense. God bless you!!!

  • @arnodorian1620
    @arnodorian1620 3 หลายเดือนก่อน

    i hope you answer just started learning java and i wanna know why you put the value "1" on your 3 variables?

  • @baltarussow7573
    @baltarussow7573 ปีที่แล้ว

    Did I miss something? What to do if the inputs have the same value? In this code the method returns the first input because of >= but that is not strictly correct in the context of the exercise? Love the tutorials by the way!

  • @KaisarAnvar
    @KaisarAnvar ปีที่แล้ว

    This was mine, would this also be acceptable? Thank you.
    *public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    System.out.println("Enter number between 1 and 100: ");
    int input1 = scan.nextInt();
    System.out.println("Enter another number between 1 and 100: ");
    int input2 = scan.nextInt();
    System.out.println("You entered the number " + input1 + " and " + input2 +
    ".
    The larger number is: " + largerNumber(input1, input2));
    }
    public static int largerNumber(int a, int b){
    int answer = Math.max(a, b);
    return answer;
    }*

  • @timdjalalov8631
    @timdjalalov8631 2 ปีที่แล้ว

    My method is written little bit differently, but works the same way, logic.
    public static void main(String[] args) {
    Scanner input = new Scanner(System.in);
    System.out.println("Enter a number between 1 and 100 : " );
    int number1 = input.nextInt();
    System.out.println("Enter a number between 1 and 100: " );
    int number 2 = input.nextInt();
    int answer = compareTwoNumbers(number1, number2);
    System.out.println("You entered the numbers " + number1 + " and " + number2 + "
    The larger number is: " + answer);
    }
    public static int compareTwoNumbers ( int a , int b){
    if ( a > b) return a ;
    else return b;
    }

  • @mex9547
    @mex9547 2 ปีที่แล้ว

    Cristal clear!!!

  • @kelvinshrivastav1858
    @kelvinshrivastav1858 5 ปีที่แล้ว

    Why we have assigned 1 to number1,number2 and largerNum?

    • @mahmoudali5623
      @mahmoudali5623 5 ปีที่แล้ว

      its not neccsary he does it so that if someone puts a invalid number like a double the program ends instead of error

    • @mohamadserhal3046
      @mohamadserhal3046 5 ปีที่แล้ว

      Mahmoud ali bro I think he forgot something he should have wrote if number >0 &&

    • @JAYCPRUDZ
      @JAYCPRUDZ 5 ปีที่แล้ว +1

      Number 1 instructor

  • @FitWithShamas
    @FitWithShamas 2 ปีที่แล้ว

    watching this in 2022! great explanation

    • @AONK
      @AONK 2 ปีที่แล้ว

      same, i can't believe this course is free