I am very new to programming and to java and I am currently working through a book called 'Introduction To Programming In Java'. I have a few problems that I want to do that I can't seem to understand. The thing is I don't really understand the questions being asked and I don't know how to get started on them. How can I practice at understanding them better and to know when/where to use what?
How would I write the code to the following questions? What would the structure consist of? (I'm not asking for any code, just advice on how to start. better understanding and what to do at each question.)
1. Suppose that a terrain is represented by a two-dimensional grid of elevation val-
ues (in meters). A peak is a grid point whose four neighbouring cells are strictly
lower. Write a program Peaks that reads a terrain from an input le and then
computes and prints the number of peaks in the terrain.
Input file format: The input file contains N x M matrix of double values, seperated by tabs (or any number of spaces). Your program must be able to read files in the .txt format and produce the correct number of peaks.
2. Write a method histogram() that takes an integer M and an array a[] of int
values as arguments and returns an array of length M whose ith entry is the
number of times the integer i appeared in the argument array. If the values in
a[] are all between 0 and M - 1, the sum of the values in the returned array
should be equal to a.length.
3. Write a method any() that takes an array of boolean values as argument and
returns true if any of the entries in the array is true, and false otherwise.
Write a method all() that takes an array of boolean values as argument and
returns true if all of the entries in the array are true, and false otherwise.
Thanks in advance