## CS 1401 Introduction to Computer Science Fall 2013, Lab 13

Objective. The main objective of this assignment is to use many concepts and techniques that you learned in this class.

Assignment. Plot how temperature and wind speed in El Paso changes with time.

First, define a class Weather each element of which has two fields: temperature t in Fahrenheit and wind speed w in miles per hour. Your class should contain a constructor method and get- and set-methods.

Your program should do the following:

• ask the user for the number of days d he/she want to input; based on this number, create a new array of objects of type Weather that will store the weather in these d days;
• for each of the d days, ask the user for temperature and wind speed, and place this information into the corresponding object;
• prepare for plotting temperature and wind; the x-axis of the standard JRaster is 200 pixels wide; thus, the points corresponding to two consecutive days shall be separated by s = 200 / d pixels:
• the first day corresponds to x0 = 0,
• the second day corresponds to x1 = s,
• the third day corresponds to x2 = 2 * s,
• ...
• the i-th day corresponds to xi − 1 = (i − 1) * s,
• the (i + 1)-st day corresponds to xi = i * s,
• ...
• the temperature ti at day i + 1 should be plotted as a point with coordinates xi = i * s and yi = 2 * ti;
• the wind speed wi at day i + 1 should be plotted as a point with coordinates xi = i * s and yi = 5 * wi;
• use different colors for temperature and wind;
• throw and catch exceptions when the data does not fit into the standard JRaster frame, i.e.:
• when we have more than 200 days, and/or
• when at least one of the corresponding values y are smaller than 0 or greater than or equal to 200;
• connect the points corresponding to consecutive days by a straight line; this means that for values x between xi and xi+1, you should take y = yi + (xxi) * (yi+1yi)/s.
Your program should consist of three methods:
• the input method that reads the data;
• the plot method that plots the data; and
• the main method that calls both input and plot, catches the exceptions thrown by the plot method and prints the appropriate error message(s).

For extra credit.

• When the data does not fit into the standard JRaster frame, plot all the data that fits before throwing an exception; e.g., if the data covers more than than 200 days, plot only from the data from first 200 days.
• For reading data, use GUI (similarly to what you did in Lab 11).

When it is due. Lab 13 is due at the beginning of the last lab, i.e.:

• on Wednesday December 4 for those who attend Monday-Wednesday labs, and
• on Thursday December 5 for those who attend Tuesday-Thursday labs.