Question: CAN SOMEONE SOLVE THE ERRORS IN THIS CODE PLEASE? AND UPLOAD IT AGAIN..SOLVED? import java.util.Scanner; public class leafpile { public static void main(String[] args) {

CAN SOMEONE SOLVE THE ERRORS IN THIS CODE PLEASE? AND UPLOAD IT AGAIN..SOLVED?

import java.util.Scanner;

public class leafpile { public static void main(String[] args) { Ground map[][] = new Ground[5][10]; generateRandomGround(map); printMap(map); System.out.println(largestLeafPile(map)); }

/***************** STUDENT CODE HERE *******************/

private static int largestLeafPile(Ground map[][]) { static int cnt; static int vis[][] = new int[1000][1000]; static void dfs(int a[][],int x,int y) { vis[x][y] = 1; if(x+1=0&&y=0&&a[x][y-1]==1&&vis[x][y-1]==0) { cnt++; dfs(a,x,y-1); } } public static void main(String args[]) { Scanner sc = new Scanner(System.in); System.out.println("Enter number of rows"); int rowcnt = sc.nextInt(); int a[][] = new int[rowcnt][]; for(int i=1;i<=rowcnt;i++) { System.out.println("Enter number of entries in column "+i); int x; x = sc.nextInt(); a[i-1] = new int[x]; } int answer = -1; String str; char ch; System.out.println("Enter the map according to the above given sizes"); for(int i=0;i cnt ? answer : cnt; } } } System.out.println("The largest pile of leaves has size : "+answer); } }

/**************** END STUDENT CODE **********************/

/************ Utility Methods *************/

private static void printMap(Ground map[][]) { for (int r = 0; r < map.length; r++) { for (int c = 0; c < map[r].length; c++) { if (map[r][c] == Ground.GRASS) { System.out.print(". "); } if (map[r][c] == Ground.LEAF) { System.out.print("~ "); } } System.out.println(); } }

private static void generateRandomGround(Ground map[][]) { int randGround; for (int r = 0; r < map.length; r++) { for (int c = 0; c < map[r].length; c++) { randGround = (int) (Math.random() * 2); map[r][c] = randGround == 0 ? Ground.GRASS : Ground.LEAF; } } }

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!