/** This program determines if all integer elements in a

/*
* This program determines if all integer elements in a two-dimensional array are identical
*  
* For example, in the 2D array ( 3 rows X 4 columns) :
*
*  7 7 7 7
*  7 7 7 7
*  7 7 7 7
*
*  all elements are equal to 7
*  
*  In the 2D array (3 rows X 2 columns):
*  
*  3 3
*  3 5
*  3 3
*  
*  one element is 5 and the others are 3 therefore the array is not all equal
*/
public class AllEqual2D
{
/**
Determines if all integer elements in a two-dimensional array are identical
@param values two-dimensional array to be examined
@return true if all values identical, false otherwise
*/
public static boolean equal values(int[][] values)
{
boolean ok = true;

 
 //———–Start below here. To do: approximate lines of code = 1
 // Declare an int variable called elem and initialize it to values[0][0];
 
 //—————–End here. Reminder: no changes outside the todo regions.

//———–Start below here. To do: approximate lines of code = 6
// Use a nested for loop (i.e. two for loops, one inside the other) that goes through
// each integer element stored in the 2D array values[][] and compares each to elem
// As soon as one comparison is false then return false. If all comparisons are true then
// the loops finish and outside of the nested loops, return true.
// Hint: values.length stores the number of rows in the 2D array, values[i].length stores the
// number of elements in row i

return false;//ok = false;

//—————–End here. Please do not remove this comment. Reminder: no changes outside the todo regions.
}

public static void main(String[] args)
{
int[][] array1 = { {0, 4, 5}, {2, 4, 9}, {0, 2, 7}, {7, 3, 6} };
int[][] array2 = { {4, 4, 4}, {4, 4, 4}, {4, 4, 4}, {4, 4, 4} };

if (equalValues(array1))
{
System.out.println(“All values in array1 are identical”);
}
if (equalValues(array2))
{
System.out.println(“All values in array2 are identical”);
}
System.out.println(“Expected:All values in array2 are identical”);
}
}

Include screenshots too for formatting.

 

Stressed over that homework?

Essay deadline breathing down your neck?

Let’s cut to the chase: Why struggle when you can ace it with zero hassle?

Whether it’s essays, research papers, or assignments — we’ve got you covered.

✅ Expert writers
✅ 100% original work
✅ No AI tools, just real pros

Stressed about your essay or homework? Get a top-quality custom essay NOW!!! Stop worrying. Start succeeding.

GradeEssays.com
We are GradeEssays.com, the best college essay writing service. We offer educational and research assistance to assist our customers in managing their academic work. At GradeEssays.com, we promise quality and 100% original essays written from scratch.
Contact Us

Enjoy 24/7 customer support for any queries or concerns you have.

Phone: +1 213 3772458

Email: support@gradeessays.com

© 2024 - GradeEssays.com. All rights reserved.

WE HAVE A GIFT FOR YOU!

15% OFF 🎁

Get 15% OFF on your order with us

Scroll to Top