Worksheet: 2D Arrays and Loops 2D arrays are helpful in storing information abou
ID: 3806784 • Letter: W
Question
Worksheet: 2D Arrays and Loops 2D arrays are helpful in storing information about data collected when a location needs to be stored. In archeology, a dig site is typically divided into a grid of one foot squares that are marked off with string. following array, grid, represents the number of artifacts found in each square of a dig site: 1. Write the code to print out the total number of square feet at the site. for (int i o i total get Length i t) system out p int in to a Write the code to find the total number of artifacts found at this dig site. 3 Write a method to count how many locations on the grid have a certain number of artifacts. So if 7 is passed in it would return 5 public state voing down Loc int a C3 int b C1 int Cor array new int al ount: 01 (int row o Yow L avvay. length row tt o I t Col o col ory ay CO 1.12 (back) SYS em. ont printin count return countExplanation / Answer
Hi, I have implemented Q4.
Please repost other in separate post.
Please let me know in case of any issue in Q4.
public class Location {
// instance variables
private int row;
private int col;
// constructor
public Location() {
row = 0;
col = 0;
}
public Location(int r, int c) {
row = r;
col = c;
}
public int getRow() {
return row;
}
public int getCol() {
return col;
}
public void setRow(int row) {
this.row = row;
}
public void setCol(int col) {
this.col = col;
}
public boolean equals(Location obj) {
if(row == obj.row && col == obj.col)
return true;
else
return false;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.