In this blog you will find the correct answer of the Coursera quiz Java Programming Principles Software Design Coursera Week 1 mixsaver always try to brings best blogs and best coupon codes
 

Week- 1

Earthquakes: Programming and Interfaces

1.
Question 1
For the assignment you wrote the method quakesOfDepth to print all the earthquakes from a data source whose depth is between a given minimum and maximum value, and also to print out the number of earthquakes found. Modify this method to run your program on the file nov20quakedata.atom (a file with information on 1518 quakes) for quakes with depth between -12,000.0 and -10,000.0, exclusive.

How many such earthquakes are there?

1 point
Enter answer here

127

2.
Question 2
For the assignment you wrote the method quakesOfDepth to print all the earthquakes from a data source whose depth is between a given minimum and maximum value, and also to print out the number of earthquakes found. Modify this method to run your program on the file nov20quakedata.atom (a file with information on 1518 quakes) for quakes with depth between -4000.0 and -2000.0, exclusive.

How many such earthquakes are there?

1 point
Enter answer here

157

3.
Question 3
For the assignment you wrote the method quakesByPhrase to print all the earthquakes from a data source whose title has a phrase in it at a specified location, and also to print out the number of earthquakes found. Modify this method to run your program on the file nov20quakedata.atom (a file with information on 1518 quakes) for quakes with the phrase “Quarry Blast” at the start of the earthquake’s title.

How many such earthquakes are there?

1 point
Enter answer here

19

4.
Question 4
For the assignment you wrote the method quakesByPhrase to print all the earthquakes from a data source whose title has a phrase in it at a specified location, and also to print out the number of earthquakes found. Modify this method to run your program on the file nov20quakedata.atom (a file with information on 1518 quakes) for quakes with the phrase “Alaska” at the end of the earthquake’s title.

How many such earthquakes are there?

1 point
Enter answer here

364

5.
Question 5
For the assignment you wrote the method quakesByPhrase to print all the earthquakes from a data source whose title has a phrase in it at a specified location, and also to print out the number of earthquakes found. Modify this method to run your program on the file nov20quakedata.atom (a file with information on 1518 quakes) for quakes with the phrase “Can” as a substring anywhere in the earthquake’s title.

How many such earthquakes are there?

1 point
Enter answer here

58

6.
Question 6
For the assignment you wrote the method findLargestQuakes to print a given number of earthquakes from a data source in order from largest magnitude. Modify this method to run your program on the file nov20quakedata.atom (a file with information on 1518 quakes) for the 20 earthquakes with the largest magnitude.

What was the magnitude of the 20th largest earthquake?

1 point
Enter answer here

5.10

7.
Question 7
For the assignment you wrote the method findLargestQuakes to print a given number of earthquakes from a data source in order from largest magnitude. Modify this method to run your program on the file nov20quakedata.atom (a file with information on 1518 quakes) for the 50 earthquakes with the largest magnitude.

What country had the 50th largest earthquake?

1 point

Solomon Islands

  • Greece
  • Kyrgyzstan
  • Indonesia
  • Japan

 

7.

For the assignment you wrote the method quakesWithFilter in the class EarthQuakeClient2 to filter earthquakes using two criteria. Modify that criteria to be those that are 1,000,000 meters (1,000 km) from Denver, Colorado whose location is (39.7392, -104.9903), and that end with an ‘a’ in their title (for example, that might be an earthquake in Nevada as that ends in ‘a’). Run your program on the file nov20quakedata.atom (a file with information on 1518 quakes). You should also print out the number of such earthquakes found.

How many such earthquakes are there?

74

 

8.
Question 8
For the assignment you wrote the method quakesWithFilter in the class EarthQuakeClient2 to filter earthquakes using two criteria. Modify that criteria to be those that are 1,000,000 meters (1,000 km) from Denver, Colorado whose location is (39.7392, -104.9903), and that end with an ‘a’ in their title (for example, that might be an earthquake in Nevada as that ends in ‘a’). Run your program on the file nov20quakedata.atom (a file with information on 1518 quakes). You should also print out the number of such earthquakes found.

How many such earthquakes are there?

1 point
Enter answer here

74

9.
Question 9
For the assignment you wrote the method quakesWithFilter in the class EarthQuakeClient2 to filter earthquakes using two criteria. Modify that critieria to be magnitude between 3.5 and 4.5 inclusive and depth between -55,000.0 and -20,000.0 inclusive. Run your program on the file nov20quakedata.atom (a file with information on 1518 quakes) with this criteria. You should also print out the number of such earthquakes found.

How many such earthquakes are there?

1 point
Enter answer here

15

10.
Question 10
For the assignment you wrote the method testMatchAllFilter in the class EarthQuakeClient2 to filter earthquakes using three criteria. Modify that criteria to be those with magnitude between 1.0 and 4.0 inclusive, to test the depth between -180,000.0 and -30,000.0 inclusive, and if the letter “o” is in the title. Modify this method to run your program on the file nov20quakedata.atom (a file with information on 1518 quakes) with the same criteria. You should also print out the number of such earthquakes found.

How many such earthquakes are there?

1 point
Enter answer here

187

11.
Question 11
For the assignment you wrote the method testMatchAllFilter2 in the class EarthQuakeClient2 to filter earthquakes using three criteria. Modify that criteria to be those with magnitude between 0.0 and 5.0 inclusive, to test for the distance from Billund, Denmark at location (55.7308, 9.1153) is less than 3,000,000 meters (3000 km), and if the letter “e” is in the title. Run your program on the file nov20quakedata.atom (a file with information on 1518 quakes) with the same criteria. You should also print out the number of such earthquakes found.

How many such earthquakes are there?

1 point
Enter answer here

17

12.
Question 12
Suppose one adds the getName( ) method to the Filter interface and adds a String parameter to the constructor of all the classes that implement a Filter to include the name of the Filter. Suppose one then creates the following code segment after reading in earthquake data into the ArrayList of QuakeData called list.

6
MatchAllFilter maf = new MatchAllFilter();
maf.addFilter(new MagnitudeFilter(3.0,5.0,”Magnitude”));
Location city = new Location(51.7308,-34.1153);
maf.addFilter(new DistanceFromFilter(3000*1000, city, “Distance”));
maf.addFilter(new PhraseFilter(“any”, “i”, “Phrase”));
System.out.println(“Filters used are: ” + maf.getName());
There are no compile errors—the DistanceFromFilter class includes “implements Filter” in the first line of the class definition, the program runs and the output is:

Filters used are: Magnitude null Phrase

Which of the following is most likely the error as to why “null” was printed instead of Distance?

1 point

  • In the DistanceFromFilter class, a private variable for the name was not assigned the value of the parameter representing the name of the filter in the Constructor method.
  • The getName( ) method in the MatchAllFilter class had a logic error in it.
  • The filter method in the EarthQuakeClient2 class has a logic error.
  • There was not a getName( ) method in the DistanceFromFilter class.

 

 

 

Important Links: