SlideShare a Scribd company logo
DO NOT use System.exit().
DO NOT add the project or package statements.
DO NOT change the class name.
DO NOT change the headers of ANY of the given methods.
DO NOT add any new class fields.
ONLY display the result as specified by the example for each problem.
DO NOT print other messages, follow the examples for each problem.
USE StdIn, StdOut, and StdRandom libraries.
No SCANNER PLEASE!
/*
*
* @author
*
* To generate weather for location at longitude -98.76 and latitude 26.70 for
* the month of February do:
* java WeatherGenerator -98.76 26.70 3
*/
public class WeatherGenerator {
static final int WET = 1; // Use this value to represent a wet day
static final int DRY = 2; // Use this value to represent a dry day
// Number of days in each month, January is index 0, February is index 1...
static final int[] numberOfDaysInMonth = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
/*
* Description:
* this method works under the assumption that under the same directory as
WeatherGenerator.java,
* there exist drywet.txt and wetwet.txt that contains probabilities of the next day being wet
* with today being a dry/wet day.
* Parameters:
* drywet & wetwet:
* 2 empty 2D arrays that will be populated, with each row in the format of:
* {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}
* you can assume that there more than enough data in the txt file,
* when there are more data in the txt files than what drywet & wetwet can store, store it up to the
array size
* Return:
* this method does not return data, the method is used to populate two 2D arrays with 14
* columns - drywet and wetwet.
* Example:
* double[][] drywet = new double[4100][14];
* double[][] wetwet = new double[4100][14];
* populateArrays(drywet, wetwet);
*/
public static void populateArrays(double[][] drywet, double[][] wetwet) {
StdIn.setFile("drywet.txt");
for(int i=0; i < drywet.length; i++){
for(int j=0; j<14; j++){
drywet[i][j] = StdIn.readDouble();
}
}
StdIn.setFile("wetwet.txt");
for(int i=0; i < drywet.length; i++){
for(int j=0; j<14; j++){
wetwet[i][j] = StdIn.readDouble();
}
}
}
/*
* Description:
* this method uses drywet and wetwet arrays populated by populateArrays, and longitude and
latitude
* of the target location to populate drywetProbability and wetwetProbability with the
* probability of dry/wet day is followed by a wet day each month at that location.
* In other words, extracting the probabilities of the location.
* parameters:
* drywetProbability: array of size 12 that will be populated with by the probability of dry days
* followed by a wet day each month
* wetwetProbability: array of size 12 that will be populated with by the probability of wet days
* followed by a wet day each month
* longitude:
* the longitude of the location
* latitude:
* the latitude of the location
* drywet:
* a 2D array of doubles populated by the method populateArrays() using drywet.txt
* wetwet:
* a 2D array of doubles populated by the method populateArrays() using wetwet.txt
* return:
* this method does not return data. The method is used to populate two 1D arrays of length
* 12 - drywetProbability and wetwetProbability.
* The probability of January is stored at index 0, February stored at index 1...
* example:
* //drywet, wetwet are populated by the method populateArrays
* double[] drywetProbability = new double[12];
* double[] wetwetProbability = new double[12];
* populateLocationProbabilities(drywetProbability, wetwetProbability, -97.58, 26.02, drywet,
wetwet);
* drywetProbability will contain the value of:
* [0.37, 0.43, 0.38, 0.48, 0.42, 0.49, 0.57, 0.70, 0.48, 0.44, 0.44, 0.36]
* wetwetProbability will contain the value of:
* [0.76, 0.75, 0.77, 0.74, 0.80, 0.86, 0.94, 0.97, 0.89, 0.77, 0.74, 0.77]
*/
public static void populateLocationProbabilities( double[] drywetProbability, double[]
wetwetProbability,
double longitude, double latitude,
double[][] drywet, double[][] wetwet){
// COMPLETE THIS METHOD
}
/*
* Description:
* Given the number of days in a month, and probabilities of weather changing at a certain
location,
* the method should return the forecast for the month.
* The first day of the month has a 50% chance to be a wet day, [0,0.5) (wet), [0.5,1) (dry)
* Use StdRandom.uniform() to generate a real number uniformly in [0,1)
* parameters:
* drywetProbability:
* a double representing the probability of next day being a wet day when the current day is a dry
day.
* wetwetProbability:
* a double representing the probability of next day being a wet day when the current day is a wet
day.
* numberOfDays:
* an integer representing how many days are in this month.
* return:
* The return should be an integer array of 1 and 2s, with the size equal to the size of the month
* 1 meaning the day is a wet day, 2 being a dry day. Index 0 being the first day of the month;
* example:
* int[] forecast = forecastGenerator( 0.27, 0.55, 31);
* Here, forecast shoule be a size 31 array of 1s and 2s, although the probability is determined,
the
* return result will still be different for each run since it is randomly generated.
*/
public static int[] forecastGenerator( double drywetProbability, double wetwetProbability, int
numberOfDays) {
// COMPLETE THIS METHOD
}
/*
* Description:
* This method takes the number of locations that is stored in wetwet.txt and drywet.txt (the
number of
* lines in each file), and takes in the month number (January is index 0, February is index 1... ),
* and the longitude and the latitude of the location we want to make the prediction on.
* This method calls all previous methods (populateArrays(), populateLocationProbabilities(),
* forecastGenerator() in this order).
* This is the only method directly called by main method to generate a forecast
* The general flow of the method:
* Firstly, use populateArrays() to extract all data into 2D arrays.
* Secondly, use populateLocationProbabilities to get the probability data of the target location
* Lastly, pass in the probability data of the month into forecastGenerator to generate a forecast
* parameters:
* numberOfLocations:
* an interger representing how many lines exists in wetwet.txt and drywet.txt
* month:
* an integer representing the month of the prediction (January is index 0, February is index 1...)
* longitude:
* a double representing the longitude of the target location.
* latitude:
* a double representing the latitude of the target location.
* return:
* return should be an integer array of 1 and 2s, with the size equal to the size of the month
* 1 meaning the day is a wet day, 2 being a dry day. index 0 being the first day of the month;
* example:
* oneMonthForecast( 4100, 0, -97.58, 26.02);
* this method call should returns an size 31 array with 1s and 2s,
* the return result will be different for each run since it is randomly generated.
*/
public static int[] oneMonthForecast(int numberOfLocations, int month, double longitude,
double latitude ){
// COMPLETE THIS METHOD
}
/********
*
* * Methods to analyze forecasts
*
******/
/*
* Description:
* Returns the number of mode (WET or DRY) days in forecast.
* parameters:
* forecast:
* an integer array of 1 and 2s, with the size equal to the size of the month
* 1 represents that the day is a wet day, 2 represents a dry day.
* index 0 is the first day of the month;
* mode:
* an integer with value of 1 (WET) or 2 (DRY).
* 1 means the method returns the number wet days.
* 2 means the method returns the number dry days.
* return:
* returns the number of mode (WET or DRY) days in forecast
* example:
* int[] arr1 = {WET,DRY,DRY,DRY};
* System.out.println(lengthOfLongestSpell(arr, DRY)); //prints out 3
* System.out.println(lengthOfLongestSpell(arr, WET)); //prints out 1
*/
public static int numberOfWetDryDays (int[] forecast, int mode) {
// COMPLETE THIS METHOD
}
/*
* Description:
* Find the longest number of consecutive mode (WET or DRY) days in forecast.
* parameters:
* forecast:
* an integer array of 1 and 2s, with the size equal to the month number of days
* represents that the day is a wet day, 2 represents a dry day.
* index 0 is the first day of the month;
* mode:
* an integer with value of 1 or 2.
* 1 means the method returns the longest stretch of consecutive wet days.
* 2 means the method returns the longest stretch of consecutive dry days.
* return:
* returns the longest number of consecutive mode (WET or DRY) days in forecast.
* example:
* int[] arr = {1,2,2,1,2,1,2,2,1,1,2,1, 2,2,2,2,2,2,2,2,2, 1,2,1,2,1,2,1,2}
* System.out.println(lengthOfLongestSpell(arr), DRY); //prints out 9
*/
public static int lengthOfLongestSpell (int[] forecast, int mode) {
// COMPLETE THIS METHOD
}
/*
* Description:
* Given the forecast of a month at certain location, this method finds the index of the
* first day of a 7 day period with the least amount of rain. If multiple exist, return
* the earliest.
* parameters:
* forecast:
* an integer array of 1 and 2s, with the size equal to the month number of days
* 1 represents the day is a wet day, 2 being a dry day.
* index 0 is the first day of the month;
* return:
* returns the index of the first day of the 7 days period with the most dry days in forecast.
* (use the earliest 7 days period with the most dry days)
* example:
* //index: 0 1 2 3 4 5 6 7 8 9 10 11 12...
* int[] arr = {1,2,2,1,2,1,2,2,1,1,2, 1, 2,2,2,2,2,2,2,2,2, 1,2,1,2,1,2,1,2}
* System.out.println(lengthOfLongestSpell(arr)); //prints out 12
*/
public static int bestWeekToTravel(int[] forecast){
// COMPLETE THIS METHOD
}
/*
* Reads the files containing the transition probabilities for US locations.
* Execution:
* java WeatherGenerator -97.58 26.02 3
*/
public static void main (String[] args) {
int numberOfRows = 4100; // Total number of locations
int numberOfColumns = 14; // Total number of 14 columns in file
// File format: longitude, latitude, 12 months of transition probabilities
double longitude = Double.parseDouble(args[0]);
double latitude = Double.parseDouble(args[1]);
int month = Integer.parseInt(args[2]);
int[] forecast = oneMonthForecast( numberOfRows, month, longitude, latitude );
int drySpell = lengthOfLongestSpell(forecast, DRY);
int wetSpell = lengthOfLongestSpell(forecast, WET);
int bestWeek = bestWeekToTravel(forecast);
StdOut.println("There are " + forecast.length + " days in the forecast for month " + month);
StdOut.println(drySpell + " days of dry spell.");
StdOut.println("The bestWeekToTravel starts on:" + bestWeek );
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) + " is forecasted to be " + weather);
}
}
}
A weather generator produces a "synthetic" time series of weather data for a location based on
the statistical characteristics of observed weather at that observations generated sequentially
through time. The special feature of a time series is that successive observations are usually
expected to be dent, in the case of forecasting a day's weather depends on the previous day's
weather. YouTube has literally thousands of videos about weather fronts and how they are
connected to the weather. This one from the UK has graphics supporting the idea of persistence
(though that word is not used). As you watch it, consider that whatever is causing weather today
(high pressure and a warm mass air creating a sunny, warm day or low pressure and a cool mass
of air creating a cloudy, cool day) is possibly still going to be affecting weather tomorrow. This
is the idea of persistence. The goal of this assignment will be to see how computation is used in
predicting long-range climate patterns. But, you might wonder how we can think about this when
we can't even predict the weather with certainty from one day to the next. Part of the answer is
that, with climate, we are trying to identify broad trends like "hotter", "wetter", "drier", not the
weather that will be experienced on any particular day. Imagine you are a farmer. Does knowing
the number of wet or dry days tell the whole story? Would the pattern be important? If so, what
pattern would you like to see? How would you measure this pattern? Weather and climate rely
on probability. It is perhaps the case that most people get their first exposure to probability
concepts from listening to weather reports. A forecaster might say "there is a 10% chance of
rain" or that "afternoon showers are likely." Probability and statistics are an integral part of day-
to-day weather forecasting because models of real-world phenomena must take into account
randomness. Randomness or uncertainty might imply ack of predictability, but it does not
necessarily imply a lack of knowledge or understanding. Weather data depends on both the time
of year and the location. This means that the probabilities used in the simulation need to be
associated with both a location and a time of year.The transition probabilities that we will use for
Norman are based on historical data, and you might use them to get a sense likelihood of certain
weather phenomena in the near future. For instance, a farmer might want to run many, many
simulations to get an idea of the likood of going 20 or more days without rain, and the results
might influence the crops that he or she plants. Just as we can base the transition probabies
historical data, we can also base them on future predictions. For instance, the National Center for
Atmospheric Research (NCAR) simulates weather as it responds to assumptions about how
various "forcings" (e.g., greenhouse gasses) will evolve in the future. Typically, these models
couple an atmospheric model with an ocean model, but more recent versions, the so-called Earth
system models, incorporate more components, including land use, sea, and land ice, etc. The
models can be used to predict future precipitation patterns and transition probabilities that are
based on these forecasts rather than past data.
Assignment Gioal Since we are just beginning as weather forecasters, we will simplify our
predictions to just whether measurable precipitation will fall from the sky. If there is measurable
precipitation, we call it a "wet" day. Otherwise, we call it a "dry" day. We will also simplify our
next day prediction based on: 1. The previous day's weather. 2. The probability of the weather
changing from dry/wet to wet of that location in that month. (Weather data) 3. A random number
Weather data depends on both the time of year and the location. This means the probabilities
used in our simulation need to be associated with location and a month. The table below lists the
probabilities that a day will be wet, given that the previous day was dry/wet for each month for a
weather station near Norman, OK. This table gives the probability of a change from dry to wet or
wet to wet. These are "real" numbers that reflect how often the weather changed from dry to wet
in that specific location, during the month indicated, over the 30-year period from 1970-2000.
Armed with these probabilities, we can turn our simulation into a weather generator for this
location. Here's what it would look like for July in Norman, OK. The box called "Random
Outcome" means that we observe some random event whose outcomes occur with the
probabilities shown on the arrows emanating from the box. If it is a dry day, we want the
outcome to simulate "next day being wet" 12% of the time and "next day being dry"
88%(100%12%) of the time. A common practice would be to use a random number generator to
generate some value between 0 and 1 . If the random value is less than .12, we can forecast the
next day to be wet, and if it is greater than .12, we can forecast the next day to be dry. If it's a wet
day, we want to simulate " next day being wet " 45% of the time and " next day being dry" 55%
of the time. To do this with our random number generator, we say there is " next day being wet "
if the random number is less than .45 and "next day being dry" if it is greater. In the simulation
flowchart to the right, note that two of the four probabilities came from the table. These are the
values shown in bold. The probabilities on the other arrows are calculated using the fact that the
probabilities must sum to 1.
Implementation You are given 2 text files named drywet.txt and wetwet.txt. wetwet.txt data file
refers to the probability of next day being a wet day if the current day is wet. drywet.txt data file
refers to the probability of next day being a wet day if the current day is dry. NOTE: the data for
the same location in wetwet.txt and drywet.txt will have the same line number. These files are in
the format of: (excerpt from wetwet.txt) In each line, the first and second numbers represent the
location's longitude and latitude. The following 12 numbers represent the probability of the next
day being a wet day of the month. For example, on the first line of the excerpt above 0.75 means
that in February (4th column), there is a 75% of chance that the next day is a wet day if today is a
wet day. Pseudocode to predict the weather for the month of June in Norman, OK (probabilities
from the table above): The first day of the month has a 50o chance to be a wet day. A value in
the range (0,0.50) means the first day is wet, a value in the range [0.501) means the first day is
dry. WHILE not all days for the month have been forecasted READ a random value between 0
and 1 IF today is a wet day THEN IF the random value is less than or equal to 0.45 THEN The
next day will be a wet day ELSE The next day will be a dry day ENDIF ELSE IF the random
value is less than or equal 0.12 THEN The next day will be a wet day ELSE The next day will be
a dry day ENDIF ENDIF ENDWHILE The weather generator methods you will be writing for
this assignment will: 1. populateLocationProbabilities: populates two arrays with the weather
data of a certain location. 2. forecastGenerator: predict future precipitation pattern for one month.
3. oneMonthForcast: use previous methods to prepare the data and predict the weather for a
month. 4. numberOfWetDryDays: find the number of wet or dry days in a given month's
forecast. 5. lengthOfLongestWetDrySpell: find the longest wet or dry spell in a given month's
forecast. 6. bestWeekToTravel: find the 7-day period with the most amount of dry days.
More details about the methods in the comments in the Java file For this assignment, since we
are dealing with randomized numbers, it can be very difficult to debug your code if it, so
AutoLab will provide you with something called a "seed" if your code fails a certain test case to
help you reproduce the error. Use StdRandom.setSeed(someLongNumber); to set the seed
provided. Doing so will cause all your future calls on StdRandom.uniform() to give the same
result on different runs of the program, allowing your program to reproduce the exact numbers
generated by Autolab. A bit more on seeds: seed (also known as random seed) is basically what
computers use to generate random numbers. True randomness does not really exist in computers.
One way to generate a random number is to take some unrelated information and process it in a
certain way such that it will generate an evenly distributed number. Oftenly, if the user(you) does
not provide StdRandom with a seed, it will generate a random seed itself. But we can manually
set seed at the beginning of your program by using StdRandom.setSeed(someLongNumber);
doing so will cause all your future calls on StdRandom.uniform() to give the same result on
different runs of the program. For example: StdRandom. setSeed ( 1617155768130L);
system.out.println( stdRandom. uniform() ); System.out.println( StdRandom. uniform() );
system. out.println( stdRandom. uniform() ); Will always result in the following numbers being
generated (in any computer): 0.8686254179738488 0.04875107145027979
0.5747992812879426 Use the provided main method 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
WeatherGenerator 98.7626.703 Always start reading code at the main() method. That will help
you understand the structure of the program.

More Related Content

Similar to DO NOT use System.exit().DO NOT add the project or package stateme.pdf

Chapter 2
Chapter 2Chapter 2
Link list
Link listLink list
Link list
Malainine Zaid
 
Oop assignment 02
Oop assignment 02Oop assignment 02
Oop assignment 02
MamoonKhan39
 
How do I fix it in LinkedList.javathis is what i didLabProgra.pdf
How do I fix it in LinkedList.javathis is what i didLabProgra.pdfHow do I fix it in LinkedList.javathis is what i didLabProgra.pdf
How do I fix it in LinkedList.javathis is what i didLabProgra.pdf
mail931892
 
Implementing of classical synchronization problem by using semaphores
Implementing of classical synchronization problem by using semaphoresImplementing of classical synchronization problem by using semaphores
Implementing of classical synchronization problem by using semaphores
Gowtham Reddy
 
Chapter 7 - Defining Your Own Classes - Part II
Chapter 7 - Defining Your Own Classes - Part IIChapter 7 - Defining Your Own Classes - Part II
Chapter 7 - Defining Your Own Classes - Part II
Eduardo Bergavera
 
Java căn bản - Chapter7
Java căn bản - Chapter7Java căn bản - Chapter7
Java căn bản - Chapter7Vince Vo
 
Tested on EclipseBoth class should be in same package.pdf
Tested on EclipseBoth class should be in same package.pdfTested on EclipseBoth class should be in same package.pdf
Tested on EclipseBoth class should be in same package.pdf
anupamagarud8
 
Please do Part A, Ill be really gratefulThe main.c is the skeleto.pdf
Please do Part A, Ill be really gratefulThe main.c is the skeleto.pdfPlease do Part A, Ill be really gratefulThe main.c is the skeleto.pdf
Please do Part A, Ill be really gratefulThe main.c is the skeleto.pdf
aioils
 
Whats new in ES2019
Whats new in ES2019Whats new in ES2019
Whats new in ES2019
chayanikaa
 
Observer and Decorator Pattern
Observer and Decorator PatternObserver and Decorator Pattern
Observer and Decorator Pattern
Jonathan Simon
 
1 CMIS 102 Hands-On Lab Week 8 Overview Th.docx
1  CMIS 102 Hands-On Lab  Week 8 Overview Th.docx1  CMIS 102 Hands-On Lab  Week 8 Overview Th.docx
1 CMIS 102 Hands-On Lab Week 8 Overview Th.docx
honey725342
 
Here is the code- I can't get it to work- I need a function that finds.pdf
Here is the code- I can't get it to work- I need a function that finds.pdfHere is the code- I can't get it to work- I need a function that finds.pdf
Here is the code- I can't get it to work- I need a function that finds.pdf
doshirajesh75
 
How do I fix it in LinkedList.javaLabProgram.javaLinkedList.jav.pdf
How do I fix it in LinkedList.javaLabProgram.javaLinkedList.jav.pdfHow do I fix it in LinkedList.javaLabProgram.javaLinkedList.jav.pdf
How do I fix it in LinkedList.javaLabProgram.javaLinkedList.jav.pdf
mail931892
 
Part 1 - Written AnswersDownload the GridWriter.zip file and exami.pdf
Part 1 - Written AnswersDownload the GridWriter.zip file and exami.pdfPart 1 - Written AnswersDownload the GridWriter.zip file and exami.pdf
Part 1 - Written AnswersDownload the GridWriter.zip file and exami.pdf
kamdinrossihoungma74
 
Cmis 102 hands on/tutorialoutlet
Cmis 102 hands on/tutorialoutletCmis 102 hands on/tutorialoutlet
Cmis 102 hands on/tutorialoutlet
Poppinss
 
Multithreaded sockets c++11
Multithreaded sockets c++11Multithreaded sockets c++11
Multithreaded sockets c++11
Russell Childs
 
Lab Assignment 4 CSE330 Spring 2014 Skeleton Code for ex.docx
 Lab Assignment 4 CSE330 Spring 2014  Skeleton Code for ex.docx Lab Assignment 4 CSE330 Spring 2014  Skeleton Code for ex.docx
Lab Assignment 4 CSE330 Spring 2014 Skeleton Code for ex.docx
MARRY7
 

Similar to DO NOT use System.exit().DO NOT add the project or package stateme.pdf (20)

Chapter 2
Chapter 2Chapter 2
Chapter 2
 
Link list
Link listLink list
Link list
 
Oop assignment 02
Oop assignment 02Oop assignment 02
Oop assignment 02
 
How do I fix it in LinkedList.javathis is what i didLabProgra.pdf
How do I fix it in LinkedList.javathis is what i didLabProgra.pdfHow do I fix it in LinkedList.javathis is what i didLabProgra.pdf
How do I fix it in LinkedList.javathis is what i didLabProgra.pdf
 
Implementing of classical synchronization problem by using semaphores
Implementing of classical synchronization problem by using semaphoresImplementing of classical synchronization problem by using semaphores
Implementing of classical synchronization problem by using semaphores
 
Chapter 7 - Defining Your Own Classes - Part II
Chapter 7 - Defining Your Own Classes - Part IIChapter 7 - Defining Your Own Classes - Part II
Chapter 7 - Defining Your Own Classes - Part II
 
cpp_sample
cpp_samplecpp_sample
cpp_sample
 
Java căn bản - Chapter7
Java căn bản - Chapter7Java căn bản - Chapter7
Java căn bản - Chapter7
 
Tested on EclipseBoth class should be in same package.pdf
Tested on EclipseBoth class should be in same package.pdfTested on EclipseBoth class should be in same package.pdf
Tested on EclipseBoth class should be in same package.pdf
 
Please do Part A, Ill be really gratefulThe main.c is the skeleto.pdf
Please do Part A, Ill be really gratefulThe main.c is the skeleto.pdfPlease do Part A, Ill be really gratefulThe main.c is the skeleto.pdf
Please do Part A, Ill be really gratefulThe main.c is the skeleto.pdf
 
Ch3
Ch3Ch3
Ch3
 
Whats new in ES2019
Whats new in ES2019Whats new in ES2019
Whats new in ES2019
 
Observer and Decorator Pattern
Observer and Decorator PatternObserver and Decorator Pattern
Observer and Decorator Pattern
 
1 CMIS 102 Hands-On Lab Week 8 Overview Th.docx
1  CMIS 102 Hands-On Lab  Week 8 Overview Th.docx1  CMIS 102 Hands-On Lab  Week 8 Overview Th.docx
1 CMIS 102 Hands-On Lab Week 8 Overview Th.docx
 
Here is the code- I can't get it to work- I need a function that finds.pdf
Here is the code- I can't get it to work- I need a function that finds.pdfHere is the code- I can't get it to work- I need a function that finds.pdf
Here is the code- I can't get it to work- I need a function that finds.pdf
 
How do I fix it in LinkedList.javaLabProgram.javaLinkedList.jav.pdf
How do I fix it in LinkedList.javaLabProgram.javaLinkedList.jav.pdfHow do I fix it in LinkedList.javaLabProgram.javaLinkedList.jav.pdf
How do I fix it in LinkedList.javaLabProgram.javaLinkedList.jav.pdf
 
Part 1 - Written AnswersDownload the GridWriter.zip file and exami.pdf
Part 1 - Written AnswersDownload the GridWriter.zip file and exami.pdfPart 1 - Written AnswersDownload the GridWriter.zip file and exami.pdf
Part 1 - Written AnswersDownload the GridWriter.zip file and exami.pdf
 
Cmis 102 hands on/tutorialoutlet
Cmis 102 hands on/tutorialoutletCmis 102 hands on/tutorialoutlet
Cmis 102 hands on/tutorialoutlet
 
Multithreaded sockets c++11
Multithreaded sockets c++11Multithreaded sockets c++11
Multithreaded sockets c++11
 
Lab Assignment 4 CSE330 Spring 2014 Skeleton Code for ex.docx
 Lab Assignment 4 CSE330 Spring 2014  Skeleton Code for ex.docx Lab Assignment 4 CSE330 Spring 2014  Skeleton Code for ex.docx
Lab Assignment 4 CSE330 Spring 2014 Skeleton Code for ex.docx
 

More from info48697

Define the terms adulteration and misbranding How are these concept.pdf
Define the terms adulteration and misbranding How are these concept.pdfDefine the terms adulteration and misbranding How are these concept.pdf
Define the terms adulteration and misbranding How are these concept.pdf
info48697
 
Define medical futility. Does the definition of futility change with.pdf
Define medical futility. Does the definition of futility change with.pdfDefine medical futility. Does the definition of futility change with.pdf
Define medical futility. Does the definition of futility change with.pdf
info48697
 
Define or explain CHAPTER 7 � Types of Tangible and Intan.pdf
Define or explain CHAPTER 7 � Types of Tangible and Intan.pdfDefine or explain CHAPTER 7 � Types of Tangible and Intan.pdf
Define or explain CHAPTER 7 � Types of Tangible and Intan.pdf
info48697
 
Define and explain social entrepreneurship Describe the corporate pu.pdf
Define and explain social entrepreneurship Describe the corporate pu.pdfDefine and explain social entrepreneurship Describe the corporate pu.pdf
Define and explain social entrepreneurship Describe the corporate pu.pdf
info48697
 
Define divisors(x) as {y Z y x}. Let a and b be two integers. Pr.pdf
Define divisors(x) as {y  Z y  x}. Let a and b be two integers. Pr.pdfDefine divisors(x) as {y  Z y  x}. Let a and b be two integers. Pr.pdf
Define divisors(x) as {y Z y x}. Let a and b be two integers. Pr.pdf
info48697
 
Define artificial intelligence. What does it mean to say that artifi.pdf
Define artificial intelligence. What does it mean to say that artifi.pdfDefine artificial intelligence. What does it mean to say that artifi.pdf
Define artificial intelligence. What does it mean to say that artifi.pdf
info48697
 
Cualquier resultado, resultado o elemento medible, tangible y verifi.pdf
Cualquier resultado, resultado o elemento medible, tangible y verifi.pdfCualquier resultado, resultado o elemento medible, tangible y verifi.pdf
Cualquier resultado, resultado o elemento medible, tangible y verifi.pdf
info48697
 
Daniel, Steven ve Chris CTde m�hendis olarak �almaktadr. irketlerin.pdf
Daniel, Steven ve Chris CTde m�hendis olarak �almaktadr. irketlerin.pdfDaniel, Steven ve Chris CTde m�hendis olarak �almaktadr. irketlerin.pdf
Daniel, Steven ve Chris CTde m�hendis olarak �almaktadr. irketlerin.pdf
info48697
 
Cuando un auditor descubre m�s de una condici�n que requiere la desv.pdf
Cuando un auditor descubre m�s de una condici�n que requiere la desv.pdfCuando un auditor descubre m�s de una condici�n que requiere la desv.pdf
Cuando un auditor descubre m�s de una condici�n que requiere la desv.pdf
info48697
 
De cara al futuro, creo que la importancia subyacente de la educaci�.pdf
De cara al futuro, creo que la importancia subyacente de la educaci�.pdfDe cara al futuro, creo que la importancia subyacente de la educaci�.pdf
De cara al futuro, creo que la importancia subyacente de la educaci�.pdf
info48697
 
david and liam have entered into a limited partnership where david i.pdf
david and liam have entered into a limited partnership where david i.pdfdavid and liam have entered into a limited partnership where david i.pdf
david and liam have entered into a limited partnership where david i.pdf
info48697
 
Dave borrowed $1,150 on January 1, 2022. The bank charged him a $4.5.pdf
Dave borrowed $1,150 on January 1, 2022. The bank charged him a $4.5.pdfDave borrowed $1,150 on January 1, 2022. The bank charged him a $4.5.pdf
Dave borrowed $1,150 on January 1, 2022. The bank charged him a $4.5.pdf
info48697
 
Data Security Read the article below and answer the following questi.pdf
Data Security Read the article below and answer the following questi.pdfData Security Read the article below and answer the following questi.pdf
Data Security Read the article below and answer the following questi.pdf
info48697
 
Daniel Browning Smith has been named the most flexible man alive. Sm.pdf
Daniel Browning Smith has been named the most flexible man alive. Sm.pdfDaniel Browning Smith has been named the most flexible man alive. Sm.pdf
Daniel Browning Smith has been named the most flexible man alive. Sm.pdf
info48697
 
d. What is the total value of the company as of year 0 e. What is.pdf
d. What is the total value of the company as of year 0 e. What is.pdfd. What is the total value of the company as of year 0 e. What is.pdf
d. What is the total value of the company as of year 0 e. What is.pdf
info48697
 
D) good genes ^^^ Which of the following isare example(s) of as.pdf
D) good genes ^^^ Which of the following isare example(s) of as.pdfD) good genes ^^^ Which of the following isare example(s) of as.pdf
D) good genes ^^^ Which of the following isare example(s) of as.pdf
info48697
 
Donita Murphy is a primary care physician at a local community pract.pdf
Donita Murphy is a primary care physician at a local community pract.pdfDonita Murphy is a primary care physician at a local community pract.pdf
Donita Murphy is a primary care physician at a local community pract.pdf
info48697
 
Dolphin Co., 2017 ylnda 1.500 $ �cret ald ve bunun 13� 2018de kaz.pdf
Dolphin Co., 2017 ylnda 1.500 $ �cret ald ve bunun 13� 2018de kaz.pdfDolphin Co., 2017 ylnda 1.500 $ �cret ald ve bunun 13� 2018de kaz.pdf
Dolphin Co., 2017 ylnda 1.500 $ �cret ald ve bunun 13� 2018de kaz.pdf
info48697
 
Do you agree with how countries in this part of the world have been .pdf
Do you agree with how countries in this part of the world have been .pdfDo you agree with how countries in this part of the world have been .pdf
Do you agree with how countries in this part of the world have been .pdf
info48697
 
Does the presence or absence of property rights make any difference .pdf
Does the presence or absence of property rights make any difference .pdfDoes the presence or absence of property rights make any difference .pdf
Does the presence or absence of property rights make any difference .pdf
info48697
 

More from info48697 (20)

Define the terms adulteration and misbranding How are these concept.pdf
Define the terms adulteration and misbranding How are these concept.pdfDefine the terms adulteration and misbranding How are these concept.pdf
Define the terms adulteration and misbranding How are these concept.pdf
 
Define medical futility. Does the definition of futility change with.pdf
Define medical futility. Does the definition of futility change with.pdfDefine medical futility. Does the definition of futility change with.pdf
Define medical futility. Does the definition of futility change with.pdf
 
Define or explain CHAPTER 7 � Types of Tangible and Intan.pdf
Define or explain CHAPTER 7 � Types of Tangible and Intan.pdfDefine or explain CHAPTER 7 � Types of Tangible and Intan.pdf
Define or explain CHAPTER 7 � Types of Tangible and Intan.pdf
 
Define and explain social entrepreneurship Describe the corporate pu.pdf
Define and explain social entrepreneurship Describe the corporate pu.pdfDefine and explain social entrepreneurship Describe the corporate pu.pdf
Define and explain social entrepreneurship Describe the corporate pu.pdf
 
Define divisors(x) as {y Z y x}. Let a and b be two integers. Pr.pdf
Define divisors(x) as {y  Z y  x}. Let a and b be two integers. Pr.pdfDefine divisors(x) as {y  Z y  x}. Let a and b be two integers. Pr.pdf
Define divisors(x) as {y Z y x}. Let a and b be two integers. Pr.pdf
 
Define artificial intelligence. What does it mean to say that artifi.pdf
Define artificial intelligence. What does it mean to say that artifi.pdfDefine artificial intelligence. What does it mean to say that artifi.pdf
Define artificial intelligence. What does it mean to say that artifi.pdf
 
Cualquier resultado, resultado o elemento medible, tangible y verifi.pdf
Cualquier resultado, resultado o elemento medible, tangible y verifi.pdfCualquier resultado, resultado o elemento medible, tangible y verifi.pdf
Cualquier resultado, resultado o elemento medible, tangible y verifi.pdf
 
Daniel, Steven ve Chris CTde m�hendis olarak �almaktadr. irketlerin.pdf
Daniel, Steven ve Chris CTde m�hendis olarak �almaktadr. irketlerin.pdfDaniel, Steven ve Chris CTde m�hendis olarak �almaktadr. irketlerin.pdf
Daniel, Steven ve Chris CTde m�hendis olarak �almaktadr. irketlerin.pdf
 
Cuando un auditor descubre m�s de una condici�n que requiere la desv.pdf
Cuando un auditor descubre m�s de una condici�n que requiere la desv.pdfCuando un auditor descubre m�s de una condici�n que requiere la desv.pdf
Cuando un auditor descubre m�s de una condici�n que requiere la desv.pdf
 
De cara al futuro, creo que la importancia subyacente de la educaci�.pdf
De cara al futuro, creo que la importancia subyacente de la educaci�.pdfDe cara al futuro, creo que la importancia subyacente de la educaci�.pdf
De cara al futuro, creo que la importancia subyacente de la educaci�.pdf
 
david and liam have entered into a limited partnership where david i.pdf
david and liam have entered into a limited partnership where david i.pdfdavid and liam have entered into a limited partnership where david i.pdf
david and liam have entered into a limited partnership where david i.pdf
 
Dave borrowed $1,150 on January 1, 2022. The bank charged him a $4.5.pdf
Dave borrowed $1,150 on January 1, 2022. The bank charged him a $4.5.pdfDave borrowed $1,150 on January 1, 2022. The bank charged him a $4.5.pdf
Dave borrowed $1,150 on January 1, 2022. The bank charged him a $4.5.pdf
 
Data Security Read the article below and answer the following questi.pdf
Data Security Read the article below and answer the following questi.pdfData Security Read the article below and answer the following questi.pdf
Data Security Read the article below and answer the following questi.pdf
 
Daniel Browning Smith has been named the most flexible man alive. Sm.pdf
Daniel Browning Smith has been named the most flexible man alive. Sm.pdfDaniel Browning Smith has been named the most flexible man alive. Sm.pdf
Daniel Browning Smith has been named the most flexible man alive. Sm.pdf
 
d. What is the total value of the company as of year 0 e. What is.pdf
d. What is the total value of the company as of year 0 e. What is.pdfd. What is the total value of the company as of year 0 e. What is.pdf
d. What is the total value of the company as of year 0 e. What is.pdf
 
D) good genes ^^^ Which of the following isare example(s) of as.pdf
D) good genes ^^^ Which of the following isare example(s) of as.pdfD) good genes ^^^ Which of the following isare example(s) of as.pdf
D) good genes ^^^ Which of the following isare example(s) of as.pdf
 
Donita Murphy is a primary care physician at a local community pract.pdf
Donita Murphy is a primary care physician at a local community pract.pdfDonita Murphy is a primary care physician at a local community pract.pdf
Donita Murphy is a primary care physician at a local community pract.pdf
 
Dolphin Co., 2017 ylnda 1.500 $ �cret ald ve bunun 13� 2018de kaz.pdf
Dolphin Co., 2017 ylnda 1.500 $ �cret ald ve bunun 13� 2018de kaz.pdfDolphin Co., 2017 ylnda 1.500 $ �cret ald ve bunun 13� 2018de kaz.pdf
Dolphin Co., 2017 ylnda 1.500 $ �cret ald ve bunun 13� 2018de kaz.pdf
 
Do you agree with how countries in this part of the world have been .pdf
Do you agree with how countries in this part of the world have been .pdfDo you agree with how countries in this part of the world have been .pdf
Do you agree with how countries in this part of the world have been .pdf
 
Does the presence or absence of property rights make any difference .pdf
Does the presence or absence of property rights make any difference .pdfDoes the presence or absence of property rights make any difference .pdf
Does the presence or absence of property rights make any difference .pdf
 

Recently uploaded

The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 

Recently uploaded (20)

The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 

DO NOT use System.exit().DO NOT add the project or package stateme.pdf

  • 1. DO NOT use System.exit(). DO NOT add the project or package statements. DO NOT change the class name. DO NOT change the headers of ANY of the given methods. DO NOT add any new class fields. ONLY display the result as specified by the example for each problem. DO NOT print other messages, follow the examples for each problem. USE StdIn, StdOut, and StdRandom libraries. No SCANNER PLEASE! /* * * @author * * To generate weather for location at longitude -98.76 and latitude 26.70 for * the month of February do: * java WeatherGenerator -98.76 26.70 3 */ public class WeatherGenerator { static final int WET = 1; // Use this value to represent a wet day static final int DRY = 2; // Use this value to represent a dry day // Number of days in each month, January is index 0, February is index 1... static final int[] numberOfDaysInMonth = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; /* * Description: * this method works under the assumption that under the same directory as WeatherGenerator.java, * there exist drywet.txt and wetwet.txt that contains probabilities of the next day being wet * with today being a dry/wet day. * Parameters: * drywet & wetwet: * 2 empty 2D arrays that will be populated, with each row in the format of: * {Longitude, Latitude, January, February, March, April, May, June, July, August, September, October, November, December}
  • 2. * {-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} * you can assume that there more than enough data in the txt file, * when there are more data in the txt files than what drywet & wetwet can store, store it up to the array size * Return: * this method does not return data, the method is used to populate two 2D arrays with 14 * columns - drywet and wetwet. * Example: * double[][] drywet = new double[4100][14]; * double[][] wetwet = new double[4100][14]; * populateArrays(drywet, wetwet); */ public static void populateArrays(double[][] drywet, double[][] wetwet) { StdIn.setFile("drywet.txt"); for(int i=0; i < drywet.length; i++){ for(int j=0; j<14; j++){ drywet[i][j] = StdIn.readDouble(); } } StdIn.setFile("wetwet.txt"); for(int i=0; i < drywet.length; i++){ for(int j=0; j<14; j++){ wetwet[i][j] = StdIn.readDouble(); } } } /* * Description: * this method uses drywet and wetwet arrays populated by populateArrays, and longitude and latitude * of the target location to populate drywetProbability and wetwetProbability with the
  • 3. * probability of dry/wet day is followed by a wet day each month at that location. * In other words, extracting the probabilities of the location. * parameters: * drywetProbability: array of size 12 that will be populated with by the probability of dry days * followed by a wet day each month * wetwetProbability: array of size 12 that will be populated with by the probability of wet days * followed by a wet day each month * longitude: * the longitude of the location * latitude: * the latitude of the location * drywet: * a 2D array of doubles populated by the method populateArrays() using drywet.txt * wetwet: * a 2D array of doubles populated by the method populateArrays() using wetwet.txt * return: * this method does not return data. The method is used to populate two 1D arrays of length * 12 - drywetProbability and wetwetProbability. * The probability of January is stored at index 0, February stored at index 1... * example: * //drywet, wetwet are populated by the method populateArrays * double[] drywetProbability = new double[12]; * double[] wetwetProbability = new double[12]; * populateLocationProbabilities(drywetProbability, wetwetProbability, -97.58, 26.02, drywet, wetwet); * drywetProbability will contain the value of: * [0.37, 0.43, 0.38, 0.48, 0.42, 0.49, 0.57, 0.70, 0.48, 0.44, 0.44, 0.36] * wetwetProbability will contain the value of: * [0.76, 0.75, 0.77, 0.74, 0.80, 0.86, 0.94, 0.97, 0.89, 0.77, 0.74, 0.77] */ public static void populateLocationProbabilities( double[] drywetProbability, double[] wetwetProbability, double longitude, double latitude, double[][] drywet, double[][] wetwet){ // COMPLETE THIS METHOD
  • 4. } /* * Description: * Given the number of days in a month, and probabilities of weather changing at a certain location, * the method should return the forecast for the month. * The first day of the month has a 50% chance to be a wet day, [0,0.5) (wet), [0.5,1) (dry) * Use StdRandom.uniform() to generate a real number uniformly in [0,1) * parameters: * drywetProbability: * a double representing the probability of next day being a wet day when the current day is a dry day. * wetwetProbability: * a double representing the probability of next day being a wet day when the current day is a wet day. * numberOfDays: * an integer representing how many days are in this month. * return: * The return should be an integer array of 1 and 2s, with the size equal to the size of the month * 1 meaning the day is a wet day, 2 being a dry day. Index 0 being the first day of the month; * example: * int[] forecast = forecastGenerator( 0.27, 0.55, 31); * Here, forecast shoule be a size 31 array of 1s and 2s, although the probability is determined, the * return result will still be different for each run since it is randomly generated. */ public static int[] forecastGenerator( double drywetProbability, double wetwetProbability, int numberOfDays) { // COMPLETE THIS METHOD } /* * Description: * This method takes the number of locations that is stored in wetwet.txt and drywet.txt (the number of
  • 5. * lines in each file), and takes in the month number (January is index 0, February is index 1... ), * and the longitude and the latitude of the location we want to make the prediction on. * This method calls all previous methods (populateArrays(), populateLocationProbabilities(), * forecastGenerator() in this order). * This is the only method directly called by main method to generate a forecast * The general flow of the method: * Firstly, use populateArrays() to extract all data into 2D arrays. * Secondly, use populateLocationProbabilities to get the probability data of the target location * Lastly, pass in the probability data of the month into forecastGenerator to generate a forecast * parameters: * numberOfLocations: * an interger representing how many lines exists in wetwet.txt and drywet.txt * month: * an integer representing the month of the prediction (January is index 0, February is index 1...) * longitude: * a double representing the longitude of the target location. * latitude: * a double representing the latitude of the target location. * return: * return should be an integer array of 1 and 2s, with the size equal to the size of the month * 1 meaning the day is a wet day, 2 being a dry day. index 0 being the first day of the month; * example: * oneMonthForecast( 4100, 0, -97.58, 26.02); * this method call should returns an size 31 array with 1s and 2s, * the return result will be different for each run since it is randomly generated. */ public static int[] oneMonthForecast(int numberOfLocations, int month, double longitude, double latitude ){ // COMPLETE THIS METHOD } /******** * * * Methods to analyze forecasts * ******/
  • 6. /* * Description: * Returns the number of mode (WET or DRY) days in forecast. * parameters: * forecast: * an integer array of 1 and 2s, with the size equal to the size of the month * 1 represents that the day is a wet day, 2 represents a dry day. * index 0 is the first day of the month; * mode: * an integer with value of 1 (WET) or 2 (DRY). * 1 means the method returns the number wet days. * 2 means the method returns the number dry days. * return: * returns the number of mode (WET or DRY) days in forecast * example: * int[] arr1 = {WET,DRY,DRY,DRY}; * System.out.println(lengthOfLongestSpell(arr, DRY)); //prints out 3 * System.out.println(lengthOfLongestSpell(arr, WET)); //prints out 1 */ public static int numberOfWetDryDays (int[] forecast, int mode) { // COMPLETE THIS METHOD } /* * Description: * Find the longest number of consecutive mode (WET or DRY) days in forecast. * parameters: * forecast: * an integer array of 1 and 2s, with the size equal to the month number of days * represents that the day is a wet day, 2 represents a dry day. * index 0 is the first day of the month; * mode: * an integer with value of 1 or 2. * 1 means the method returns the longest stretch of consecutive wet days. * 2 means the method returns the longest stretch of consecutive dry days.
  • 7. * return: * returns the longest number of consecutive mode (WET or DRY) days in forecast. * example: * int[] arr = {1,2,2,1,2,1,2,2,1,1,2,1, 2,2,2,2,2,2,2,2,2, 1,2,1,2,1,2,1,2} * System.out.println(lengthOfLongestSpell(arr), DRY); //prints out 9 */ public static int lengthOfLongestSpell (int[] forecast, int mode) { // COMPLETE THIS METHOD } /* * Description: * Given the forecast of a month at certain location, this method finds the index of the * first day of a 7 day period with the least amount of rain. If multiple exist, return * the earliest. * parameters: * forecast: * an integer array of 1 and 2s, with the size equal to the month number of days * 1 represents the day is a wet day, 2 being a dry day. * index 0 is the first day of the month; * return: * returns the index of the first day of the 7 days period with the most dry days in forecast. * (use the earliest 7 days period with the most dry days) * example: * //index: 0 1 2 3 4 5 6 7 8 9 10 11 12... * int[] arr = {1,2,2,1,2,1,2,2,1,1,2, 1, 2,2,2,2,2,2,2,2,2, 1,2,1,2,1,2,1,2} * System.out.println(lengthOfLongestSpell(arr)); //prints out 12 */ public static int bestWeekToTravel(int[] forecast){ // COMPLETE THIS METHOD } /* * Reads the files containing the transition probabilities for US locations. * Execution: * java WeatherGenerator -97.58 26.02 3
  • 8. */ public static void main (String[] args) { int numberOfRows = 4100; // Total number of locations int numberOfColumns = 14; // Total number of 14 columns in file // File format: longitude, latitude, 12 months of transition probabilities double longitude = Double.parseDouble(args[0]); double latitude = Double.parseDouble(args[1]); int month = Integer.parseInt(args[2]); int[] forecast = oneMonthForecast( numberOfRows, month, longitude, latitude ); int drySpell = lengthOfLongestSpell(forecast, DRY); int wetSpell = lengthOfLongestSpell(forecast, WET); int bestWeek = bestWeekToTravel(forecast); StdOut.println("There are " + forecast.length + " days in the forecast for month " + month); StdOut.println(drySpell + " days of dry spell."); StdOut.println("The bestWeekToTravel starts on:" + bestWeek ); 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) + " is forecasted to be " + weather); } } } A weather generator produces a "synthetic" time series of weather data for a location based on the statistical characteristics of observed weather at that observations generated sequentially through time. The special feature of a time series is that successive observations are usually expected to be dent, in the case of forecasting a day's weather depends on the previous day's weather. YouTube has literally thousands of videos about weather fronts and how they are connected to the weather. This one from the UK has graphics supporting the idea of persistence (though that word is not used). As you watch it, consider that whatever is causing weather today (high pressure and a warm mass air creating a sunny, warm day or low pressure and a cool mass of air creating a cloudy, cool day) is possibly still going to be affecting weather tomorrow. This is the idea of persistence. The goal of this assignment will be to see how computation is used in
  • 9. predicting long-range climate patterns. But, you might wonder how we can think about this when we can't even predict the weather with certainty from one day to the next. Part of the answer is that, with climate, we are trying to identify broad trends like "hotter", "wetter", "drier", not the weather that will be experienced on any particular day. Imagine you are a farmer. Does knowing the number of wet or dry days tell the whole story? Would the pattern be important? If so, what pattern would you like to see? How would you measure this pattern? Weather and climate rely on probability. It is perhaps the case that most people get their first exposure to probability concepts from listening to weather reports. A forecaster might say "there is a 10% chance of rain" or that "afternoon showers are likely." Probability and statistics are an integral part of day- to-day weather forecasting because models of real-world phenomena must take into account randomness. Randomness or uncertainty might imply ack of predictability, but it does not necessarily imply a lack of knowledge or understanding. Weather data depends on both the time of year and the location. This means that the probabilities used in the simulation need to be associated with both a location and a time of year.The transition probabilities that we will use for Norman are based on historical data, and you might use them to get a sense likelihood of certain weather phenomena in the near future. For instance, a farmer might want to run many, many simulations to get an idea of the likood of going 20 or more days without rain, and the results might influence the crops that he or she plants. Just as we can base the transition probabies historical data, we can also base them on future predictions. For instance, the National Center for Atmospheric Research (NCAR) simulates weather as it responds to assumptions about how various "forcings" (e.g., greenhouse gasses) will evolve in the future. Typically, these models couple an atmospheric model with an ocean model, but more recent versions, the so-called Earth system models, incorporate more components, including land use, sea, and land ice, etc. The models can be used to predict future precipitation patterns and transition probabilities that are based on these forecasts rather than past data. Assignment Gioal Since we are just beginning as weather forecasters, we will simplify our predictions to just whether measurable precipitation will fall from the sky. If there is measurable precipitation, we call it a "wet" day. Otherwise, we call it a "dry" day. We will also simplify our next day prediction based on: 1. The previous day's weather. 2. The probability of the weather changing from dry/wet to wet of that location in that month. (Weather data) 3. A random number Weather data depends on both the time of year and the location. This means the probabilities used in our simulation need to be associated with location and a month. The table below lists the probabilities that a day will be wet, given that the previous day was dry/wet for each month for a weather station near Norman, OK. This table gives the probability of a change from dry to wet or wet to wet. These are "real" numbers that reflect how often the weather changed from dry to wet
  • 10. in that specific location, during the month indicated, over the 30-year period from 1970-2000. Armed with these probabilities, we can turn our simulation into a weather generator for this location. Here's what it would look like for July in Norman, OK. The box called "Random Outcome" means that we observe some random event whose outcomes occur with the probabilities shown on the arrows emanating from the box. If it is a dry day, we want the outcome to simulate "next day being wet" 12% of the time and "next day being dry" 88%(100%12%) of the time. A common practice would be to use a random number generator to generate some value between 0 and 1 . If the random value is less than .12, we can forecast the next day to be wet, and if it is greater than .12, we can forecast the next day to be dry. If it's a wet day, we want to simulate " next day being wet " 45% of the time and " next day being dry" 55% of the time. To do this with our random number generator, we say there is " next day being wet " if the random number is less than .45 and "next day being dry" if it is greater. In the simulation flowchart to the right, note that two of the four probabilities came from the table. These are the values shown in bold. The probabilities on the other arrows are calculated using the fact that the probabilities must sum to 1. Implementation You are given 2 text files named drywet.txt and wetwet.txt. wetwet.txt data file refers to the probability of next day being a wet day if the current day is wet. drywet.txt data file refers to the probability of next day being a wet day if the current day is dry. NOTE: the data for the same location in wetwet.txt and drywet.txt will have the same line number. These files are in the format of: (excerpt from wetwet.txt) In each line, the first and second numbers represent the location's longitude and latitude. The following 12 numbers represent the probability of the next day being a wet day of the month. For example, on the first line of the excerpt above 0.75 means that in February (4th column), there is a 75% of chance that the next day is a wet day if today is a wet day. Pseudocode to predict the weather for the month of June in Norman, OK (probabilities from the table above): The first day of the month has a 50o chance to be a wet day. A value in the range (0,0.50) means the first day is wet, a value in the range [0.501) means the first day is dry. WHILE not all days for the month have been forecasted READ a random value between 0 and 1 IF today is a wet day THEN IF the random value is less than or equal to 0.45 THEN The next day will be a wet day ELSE The next day will be a dry day ENDIF ELSE IF the random value is less than or equal 0.12 THEN The next day will be a wet day ELSE The next day will be a dry day ENDIF ENDIF ENDWHILE The weather generator methods you will be writing for this assignment will: 1. populateLocationProbabilities: populates two arrays with the weather data of a certain location. 2. forecastGenerator: predict future precipitation pattern for one month. 3. oneMonthForcast: use previous methods to prepare the data and predict the weather for a month. 4. numberOfWetDryDays: find the number of wet or dry days in a given month's
  • 11. forecast. 5. lengthOfLongestWetDrySpell: find the longest wet or dry spell in a given month's forecast. 6. bestWeekToTravel: find the 7-day period with the most amount of dry days. More details about the methods in the comments in the Java file For this assignment, since we are dealing with randomized numbers, it can be very difficult to debug your code if it, so AutoLab will provide you with something called a "seed" if your code fails a certain test case to help you reproduce the error. Use StdRandom.setSeed(someLongNumber); to set the seed provided. Doing so will cause all your future calls on StdRandom.uniform() to give the same result on different runs of the program, allowing your program to reproduce the exact numbers generated by Autolab. A bit more on seeds: seed (also known as random seed) is basically what computers use to generate random numbers. True randomness does not really exist in computers. One way to generate a random number is to take some unrelated information and process it in a certain way such that it will generate an evenly distributed number. Oftenly, if the user(you) does not provide StdRandom with a seed, it will generate a random seed itself. But we can manually set seed at the beginning of your program by using StdRandom.setSeed(someLongNumber); doing so will cause all your future calls on StdRandom.uniform() to give the same result on different runs of the program. For example: StdRandom. setSeed ( 1617155768130L); system.out.println( stdRandom. uniform() ); System.out.println( StdRandom. uniform() ); system. out.println( stdRandom. uniform() ); Will always result in the following numbers being generated (in any computer): 0.8686254179738488 0.04875107145027979 0.5747992812879426 Use the provided main method 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 WeatherGenerator 98.7626.703 Always start reading code at the main() method. That will help you understand the structure of the program.