Future transition probability table as a 2D array The oneMonthGenerator method receives as arguments the transition probability tables (dry to wet, and wet to wet) as 2D arrays. Each table row...


java problem:


1.predict future precipitation pattern for one month: oneMonthGenerator


2.find the number of wet or dry days in a given month’s forecast: numberOfWetDryDays


3.find the longest wet or dry spell in a given month’s forecast: lengthOfLongestWetDrySpell


Future transition probability table as a 2D array<br>The oneMonthGenerator method receives as arguments the transition probability tables (dry to wet, and wet to wet) as 2D arrays.<br>Each table row corresponds to a location (longitude, latitude) in the USA and contains the transition probabilities<br>for each month of the year.<br>Longitude Latitude January February March April May June July August September October November December<br>-97.58<br>26.02<br>0.76<br>0.75<br>0.77<br>0.74 0.80 0.86 0.94 0.97<br>0.89<br>0.77<br>0.74<br>0.77<br>Following are the methods to be completed in WeatherGenerator.java:<br>public class WeatherGenerator {<br>/* Given a location (longitude, latitude) in the USA and a month of the year, the method<br>* returns the forecast for the month based on the drywet and wetwet transition<br>* probabilities tables.<br>* month will be a value between 2 and 13: 2 corresponds to January, 3 corresponds to February<br>* and so on. These are the column indexes of each month in the transition probabilities tables.<br>* The first day of the month has a 50% chance to be a wet day, 0-0.49 (wet), 0.50-0.99 (dry)<br>* Use StdRandom.uniform ( ) to generate a real number uniformly in [0,1)<br>*/<br>int[] oneMonthGenerator (double longitute, double latitude, int month, double[][] drywet, double[][] wetwet)<br>// Returns the longest number of consecutive mode (WET or DRY) days in forecast.<br>int numberofWetDryDays (int[] forecast, int mode)<br>/*<br>* Analyzes the forecast array and returns the longest number of<br>* consecutive mode (which can be WET or DRY) days in forecast.<br>*/<br>int lengthofLongestWetDrySpell (int[] forecast, int mode)<br>

Extracted text: Future transition probability table as a 2D array The oneMonthGenerator method receives as arguments the transition probability tables (dry to wet, and wet to wet) as 2D arrays. Each table row corresponds to a location (longitude, latitude) in the USA and contains the transition probabilities for each month of the year. Longitude Latitude January February March April May June July August September October November December -97.58 26.02 0.76 0.75 0.77 0.74 0.80 0.86 0.94 0.97 0.89 0.77 0.74 0.77 Following are the methods to be completed in WeatherGenerator.java: public class WeatherGenerator { /* Given a location (longitude, latitude) in the USA and a month of the year, the method * returns the forecast for the month based on the drywet and wetwet transition * probabilities tables. * month will be a value between 2 and 13: 2 corresponds to January, 3 corresponds to February * and so on. These are the column indexes of each month in the transition probabilities tables. * The first day of the month has a 50% chance to be a wet day, 0-0.49 (wet), 0.50-0.99 (dry) * Use StdRandom.uniform ( ) to generate a real number uniformly in [0,1) */ int[] oneMonthGenerator (double longitute, double latitude, int month, double[][] drywet, double[][] wetwet) // Returns the longest number of consecutive mode (WET or DRY) days in forecast. int numberofWetDryDays (int[] forecast, int mode) /* * Analyzes the forecast array and returns the longest number of * consecutive mode (which can be WET or DRY) days in forecast. */ int lengthofLongestWetDrySpell (int[] forecast, int mode)
Use the main method as a driver to test your methods. To generate the weather for location at longitude -98.76 and latitude 26.70 for the month of<br>February do:<br>java WeatherGeneratorl11 -98.76 26.70 3<br>public static void main (String[] args) {<br>int numberofRows<br>= 4001; // Total number of locations<br>// Total number of 14 columns in file<br>// File format: longitude, latitude, 12 months of transition probabilities<br>int numberofColumns = 14;<br>// Allocate and populate arrays that hold the transition probabilities<br>double[][] drywet = new double[numberofRows ] [numberofColumns];<br>double[][] wetwet = new double[numberofRows ] [numberofColumns];<br>populateTransitionProbabilitiesArrays (drywet, wetwet, numberofRows);<br>/*** WRITE YOUR CODE BELLOW THIS LINE. DO NOT erase any of the lines above. ***/<br>// Read command line inputs<br>double longitute = Double.parseDouble (args[0]);<br>= Double.parseDouble (args[1]);<br>= Integer.parseInt (args[2]);<br>double latitude<br>int<br>month<br>int[] forecast = oneMonthGenerator (longitute, latitude, month, drywet, wetwet);<br>int drySpell = lengthofLongestSpell(forecast, DRY);<br>int wetSpell = lengthofLongestSpell(forecast, WET);<br>+ month);<br>Stdout.println(

Extracted text: Use the main method as a driver to test your methods. To generate the weather for location at longitude -98.76 and latitude 26.70 for the month of February do: java WeatherGeneratorl11 -98.76 26.70 3 public static void main (String[] args) { int numberofRows = 4001; // Total number of locations // Total number of 14 columns in file // File format: longitude, latitude, 12 months of transition probabilities int numberofColumns = 14; // Allocate and populate arrays that hold the transition probabilities double[][] drywet = new double[numberofRows ] [numberofColumns]; double[][] wetwet = new double[numberofRows ] [numberofColumns]; populateTransitionProbabilitiesArrays (drywet, wetwet, numberofRows); /*** WRITE YOUR CODE BELLOW THIS LINE. DO NOT erase any of the lines above. ***/ // Read command line inputs double longitute = Double.parseDouble (args[0]); = Double.parseDouble (args[1]); = Integer.parseInt (args[2]); double latitude int month int[] forecast = oneMonthGenerator (longitute, latitude, month, drywet, wetwet); int drySpell = lengthofLongestSpell(forecast, DRY); int wetSpell = lengthofLongestSpell(forecast, WET); + month); Stdout.println("There are " + forecast.length + " days in the forecast for month " Stdout.println(drySpell + " days of dry spell."); for ( int i = 0; i < forecast.length; i++ ) { // this is the ternary operator. (conditional) ? executed if true : executed if false string weather = (forecast[i] == wet) ? "wet" : "dry"; stdout.println("day } + (i+1) + " is forecasted to be + weather); forecast.length;="" i++="" )="" {="" this="" is="" the="" ternary="" operator.="" (conditional)="" executed="" if="" true="" :="" executed="" if="" false="" string="" weather="(forecast[i]" =="WET)" "wet"="" :="" "dry";="" stdout.println("day="" }="" +="" (i+1)="" +="" "="" is="" forecasted="" to="" be="" +="">
Jun 04, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here