Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 7 of 7

Thread: Need help

  1. #1
    Junior Member
    Join Date
    May 2019
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Need help

    Hello, I'm new in programming with Java, i learnt today about if, else if, else and i've got some homework. But one of the tasks is the following: I need to type 3 numbers and if they are euqal to get "yes" and if they are not to get "no". I just don't get how to do this and there's a hint that says to look for information for &&, but i haven't learnt about this or i've missed it . Would be happy if someone of you helps me out a little bit.

  2. #2
    Member
    Join Date
    Sep 2018
    Location
    Virginia
    Posts
    284
    My Mood
    Cool
    Thanks
    0
    Thanked 38 Times in 36 Posts

    Default Re: Need help

    This is basic Java so you should check out the tutorials in my signature. The questions you raise are covered in there.

    Regards,
    Jim

  3. #3
    Member John Joe's Avatar
    Join Date
    Jun 2017
    Posts
    277
    My Mood
    Amused
    Thanks
    8
    Thanked 19 Times in 19 Posts

    Default Re: Need help

    I think is similar to this?

    If((num1 == num2) && (num2 == num3)){
          System.out.print("Yes");
    }
    Whatever you are, be a good one

  4. #4
    Junior Member
    Join Date
    May 2019
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Need help

    Quote Originally Posted by John Joe View Post
    I think is similar to this?

    If((num1 == num2) && (num2 == num3)){
          System.out.print("Yes");
    }
    Exactly this! Thanks man !

  5. #5
    Junior Member
    Join Date
    Apr 2020
    Location
    Jacksonville, FL
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Need help

    Thanks!

  6. #6
    Member
    Join Date
    Jan 2024
    Posts
    75
    Thanks
    0
    Thanked 4 Times in 4 Posts

    Default Re: Need help

    Certainly! Here's a solution using Java:

    ```java
    import java.util.Scanner;

    public class Main {
    public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    System.out.println("Enter three numbers:");
    int num1 = scanner.nextInt();
    int num2 = scanner.nextInt();
    int num3 = scanner.nextInt();

    if (num1 == num2 && num2 == num3) {
    System.out.println("yes");
    } else {
    System.out.println("no");
    }

    scanner.close();
    }
    }
    ```

    This program first prompts the user to enter three numbers. Then, it compares if all three numbers are equal using the `==` operator and the logical AND operator `&&`. If they are all equal, it prints "yes", otherwise, it prints "no". Make sure to input integers when prompted!

    If you're still struggling with your Java assignment and need further assistance, there are plenty of resources available online to help guide you through. Consider seeking out additional tutorials or forums where you can ask questions and learn from others' experiences. Sometimes, a different perspective can make all the difference in understanding a concept. Keep practicing, and you'll get there! Additionally, professional assistance from reputable sources like programminghomeworkhelp.com can provide valuable insights and support when tackling complex assignments. Just remember to approach such resources with caution and verify their credibility. Happy coding and good luck with your Java assignment!

  7. #7
    Member
    Join Date
    Jan 2024
    Posts
    75
    Thanks
    0
    Thanked 4 Times in 4 Posts

    Default Re: Need help

    Sure, I can help you with that! Here's a simple solution using if-else statements:

    ```java
    import java.util.Scanner;

    public class Main {
    public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    System.out.println("Enter three numbers:");
    int num1 = scanner.nextInt();
    int num2 = scanner.nextInt();
    int num3 = scanner.nextInt();

    if (num1 == num2 && num2 == num3) {
    System.out.println("yes");
    } else {
    System.out.println("no");
    }

    scanner.close();
    }
    }
    ```

    In this code, we first prompt the user to enter three numbers. Then, we use if-else statements to check if all three numbers are equal. If they are, we print "yes", otherwise we print "no". The && is a logical AND operator which checks if both conditions on its left and right sides are true. So in this case, it checks if all three numbers are equal. If you're looking for further help with Java assignment, there are resources available online that can provide guidance and support, such as programminghomeworkhelp.com.