The goal of this lab is to:
Many of the problems in the Basic Array Problems are similar to the methods you must implement below. Try to do the problems below first but if you have trouble, take a look at the solutions for the Basic Array Problems. Many of these basic problems will be covered in class and are also discussed in your text.
Once you are comfortable working with arrays, try the following exercise which examines temperature data for Salem.
Create a Netbeans project containing main(). Download the class Temperatures.java and place in your project folder. Note, you may need to rename the package name to match your package name.
The Temperatures class contains a member variable which is a 1D array of doubles containing the average July temperatures for Salem from 1903 to 2015. It also has a member variable containing the starting year, 1903. Several methods are given, but the code is incomplete.
Your task is to complete these methods:
year: 1903 temperature = 63.6
year: 1904 temperature = 66.8
year: 1905 temperature = 68.8
year: 1906 temperature = 72.0
...
year: 2012 temperature = 66.8
year: 2013 temperature = 70.5
year: 2014 temperature = 72.5
year: 2015 temperature = 72.8
The simplest approach to coding this is to round each temperature to an integer (e.g. 64.6 will become 65) and, using a loop, print the number of "*"s equal to this rounded temperature (e.g. draw 65 "*"s). The graph for the first 5 years should look like:
Salem Mean July Temperatures
1903: 63.6 ****************************************************************
1904: 66.8 *******************************************************************
1905: 68.8 *********************************************************************
1906: 72.0 ************************************************************************
1907: 67.6 ********************************************************************
To test your program, execute the following code below in main. You can compare your output to output.txt.
Temperatures t = new Temperatures();
System.out.println("Average temperature is " + t.calcAverage()); // should be around 67
System.out.println("Max temperature is " + t.calcMax()); // should be 72.8
System.out.println("Min temperature is " + t.calcMin()); // should be 61.9
t.graph();
You are encouraged but not required to demo your completed Temperatures class to the instructor or lab assistant.
In the above program, you worked with an 1D array. In this part of the lab, you will work with a 2D array.
Instructions:
TicTacToe tictactoe = new TicTacToe();
tictactoe.play();
Tools->Analyze Javadoc
This will let you know if there are any errors in your Javadoc and also it will generate the Javadoc, placing it in dist/Javadoc folder of the project.
To receive full credit, you need to:
Make sure that your Java code:
Demonstrate:
Submit your TicTacToe.java to Wise as an attachment to Lab 7