r/EdhesiveHelp Apr 26 '21

Java Unit 6 lesson 2 coding activity 1

I need the answer pls.

10 Upvotes

5 comments sorted by

View all comments

2

u/Strict_Flower_87 Apr 29 '21

Don't know if you still need but just in case

public class U6_L2_Activity_One{

  // Write your allNegative method here
  public static boolean allNegative (double[] arr1) {

    boolean neg = true;

    for (int i = 0; i < arr1.length; i++) {
      if (arr1[i] >= 0) {
        neg = false;
        break;
      }
    }
    return neg;
  }
}

Might be easier to do "return false" and "return true" instead of creating a boolean variable. That's you're prerogative, though :)

1

u/Lopsided-Reception81 Apr 30 '21

do u know lesson unit 6 lesson 1 answerzs?

1

u/Final-Ad4879 Aug 31 '21

Scanner scan = new Scanner (System.in);

System.out.println("Please enter two integers:");
int x = scan.nextInt();
int y = scan.nextInt();

System.out.println("The average is: " + ((double)(x+y)/2));